Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between getters and setters in order to be able to provide beans with properties with a common type when type safety is taken in account like with Kotlin. It also add a few missing property level @Nullable annotations. Issue: SPR-15792
This commit is contained in:
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManager {
|
||||
|
||||
@Nullable
|
||||
private net.sf.ehcache.CacheManager cacheManager;
|
||||
|
||||
|
||||
@@ -59,7 +60,7 @@ public class EhCacheCacheManager extends AbstractTransactionSupportingCacheManag
|
||||
/**
|
||||
* Set the backing EhCache {@link net.sf.ehcache.CacheManager}.
|
||||
*/
|
||||
public void setCacheManager(net.sf.ehcache.CacheManager cacheManager) {
|
||||
public void setCacheManager(@Nullable net.sf.ehcache.CacheManager cacheManager) {
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {
|
||||
|
||||
@Nullable
|
||||
private javax.cache.CacheManager cacheManager;
|
||||
|
||||
private boolean allowNullValues = true;
|
||||
@@ -62,7 +63,7 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
|
||||
/**
|
||||
* Set the backing JCache {@link javax.cache.CacheManager}.
|
||||
*/
|
||||
public void setCacheManager(javax.cache.CacheManager cacheManager) {
|
||||
public void setCacheManager(@Nullable javax.cache.CacheManager cacheManager) {
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
* Set the default {@link CacheManager} to use to lookup cache by name. Only mandatory
|
||||
* if the {@linkplain CacheResolver cache resolvers} have not been set.
|
||||
*/
|
||||
public void setCacheManager(CacheManager cacheManager) {
|
||||
public void setCacheManager(@Nullable CacheManager cacheManager) {
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
* Set the {@link CacheResolver} to resolve regular caches. If none is set, a default
|
||||
* implementation using the specified cache manager will be used.
|
||||
*/
|
||||
public void setCacheResolver(CacheResolver cacheResolver) {
|
||||
public void setCacheResolver(@Nullable CacheResolver cacheResolver) {
|
||||
this.cacheResolver = cacheResolver;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
* Set the {@link CacheResolver} to resolve exception caches. If none is set, a default
|
||||
* implementation using the specified cache manager will be used.
|
||||
*/
|
||||
public void setExceptionCacheResolver(CacheResolver exceptionCacheResolver) {
|
||||
public void setExceptionCacheResolver(@Nullable CacheResolver exceptionCacheResolver) {
|
||||
this.exceptionCacheResolver = exceptionCacheResolver;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class DefaultJCacheOperationSource extends AnnotationJCacheOperationSourc
|
||||
* honoring the JSR-107 {@link javax.cache.annotation.CacheKey} and
|
||||
* {@link javax.cache.annotation.CacheValue} will be used.
|
||||
*/
|
||||
public void setKeyGenerator(KeyGenerator keyGenerator) {
|
||||
public void setKeyGenerator(@Nullable KeyGenerator keyGenerator) {
|
||||
this.keyGenerator = keyGenerator;
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
|
||||
|
||||
@Override
|
||||
public void setFrom(String from) {
|
||||
public void setFrom(@Nullable String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(String replyTo) {
|
||||
public void setReplyTo(@Nullable String replyTo) {
|
||||
this.replyTo = replyTo;
|
||||
}
|
||||
|
||||
@@ -118,12 +118,12 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTo(String to) {
|
||||
public void setTo(@Nullable String to) {
|
||||
this.to = new String[] {to};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTo(String[] to) {
|
||||
public void setTo(@Nullable String[] to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@@ -133,12 +133,12 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCc(String cc) {
|
||||
public void setCc(@Nullable String cc) {
|
||||
this.cc = new String[] {cc};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCc(String[] cc) {
|
||||
public void setCc(@Nullable String[] cc) {
|
||||
this.cc = cc;
|
||||
}
|
||||
|
||||
@@ -148,12 +148,12 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBcc(String bcc) {
|
||||
public void setBcc(@Nullable String bcc) {
|
||||
this.bcc = new String[] {bcc};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBcc(String[] bcc) {
|
||||
public void setBcc(@Nullable String[] bcc) {
|
||||
this.bcc = bcc;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSentDate(Date sentDate) {
|
||||
public void setSentDate(@Nullable Date sentDate) {
|
||||
this.sentDate = sentDate;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubject(String subject) {
|
||||
public void setSubject(@Nullable String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public class SimpleMailMessage implements MailMessage, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
public void setText(@Nullable String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
@Nullable
|
||||
private String defaultEncoding;
|
||||
|
||||
@Nullable
|
||||
private FileTypeMap defaultFileTypeMap;
|
||||
|
||||
|
||||
@@ -165,7 +166,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
/**
|
||||
* Set the mail protocol. Default is "smtp".
|
||||
*/
|
||||
public void setProtocol(String protocol) {
|
||||
public void setProtocol(@Nullable String protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
@@ -181,7 +182,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* Set the mail server host, typically an SMTP host.
|
||||
* <p>Default is the default host of the underlying JavaMail Session.
|
||||
*/
|
||||
public void setHost(String host) {
|
||||
public void setHost(@Nullable String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* @see #setSession
|
||||
* @see #setPassword
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
public void setUsername(@Nullable String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@@ -243,7 +244,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* @see #setSession
|
||||
* @see #setUsername
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
public void setPassword(@Nullable String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@@ -260,7 +261,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* created by this instance.
|
||||
* <p>Such an encoding will be auto-detected by {@link MimeMessageHelper}.
|
||||
*/
|
||||
public void setDefaultEncoding(String defaultEncoding) {
|
||||
public void setDefaultEncoding(@Nullable String defaultEncoding) {
|
||||
this.defaultEncoding = defaultEncoding;
|
||||
}
|
||||
|
||||
@@ -286,7 +287,7 @@ public class JavaMailSenderImpl implements JavaMailSender {
|
||||
* {@code mime.types} file contained in the Spring jar).
|
||||
* @see MimeMessageHelper#setFileTypeMap
|
||||
*/
|
||||
public void setDefaultFileTypeMap(FileTypeMap defaultFileTypeMap) {
|
||||
public void setDefaultFileTypeMap(@Nullable FileTypeMap defaultFileTypeMap) {
|
||||
this.defaultFileTypeMap = defaultFileTypeMap;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user