Add missing @Nullable annotations on parameters
Issue: SPR-15540
This commit is contained in:
@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportAware;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
@@ -80,7 +81,7 @@ public abstract class AbstractCachingConfiguration implements ImportAware {
|
||||
/**
|
||||
* Extract the configuration from the nominated {@link CachingConfigurer}.
|
||||
*/
|
||||
protected void useCachingConfigurer(CachingConfigurer config) {
|
||||
protected void useCachingConfigurer(@Nullable CachingConfigurer config) {
|
||||
this.cacheManager = config.cacheManager();
|
||||
this.cacheResolver = config.cacheResolver();
|
||||
this.keyGenerator = config.keyGenerator();
|
||||
|
||||
@@ -137,7 +137,8 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
@Nullable
|
||||
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
|
||||
if (this.store.containsKey(key)) {
|
||||
return (T) get(key).get();
|
||||
}
|
||||
@@ -154,18 +155,19 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
public void put(@Nullable Object key, @Nullable Object value) {
|
||||
this.store.put(key, toStoreValue(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper putIfAbsent(Object key, Object value) {
|
||||
@Nullable
|
||||
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
|
||||
Object existing = this.store.putIfAbsent(key, toStoreValue(value));
|
||||
return toValueWrapper(existing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
public void evict(@Nullable Object key) {
|
||||
this.store.remove(key);
|
||||
}
|
||||
|
||||
@@ -175,7 +177,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object toStoreValue(Object userValue) {
|
||||
protected Object toStoreValue(@Nullable Object userValue) {
|
||||
Object storeValue = super.toStoreValue(userValue);
|
||||
if (this.serialization != null) {
|
||||
try {
|
||||
@@ -203,7 +205,7 @@ public class ConcurrentMapCache extends AbstractValueAdaptingCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object fromStoreValue(Object storeValue) {
|
||||
protected Object fromStoreValue(@Nullable Object storeValue) {
|
||||
if (this.serialization != null) {
|
||||
try {
|
||||
return super.fromStoreValue(deserializeValue(storeValue));
|
||||
|
||||
@@ -146,7 +146,7 @@ public class ConcurrentMapCacheManager implements CacheManager, BeanClassLoaderA
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.serialization = new SerializationDelegate(classLoader);
|
||||
// Need to recreate all Cache instances with new ClassLoader in store-by-value mode...
|
||||
if (isStoreByValue()) {
|
||||
|
||||
@@ -95,6 +95,6 @@ public abstract class AbstractCacheResolver implements CacheResolver, Initializi
|
||||
* @return the cache name(s) to resolve or {@code null} if no cache should be resolved
|
||||
*/
|
||||
@Nullable
|
||||
protected abstract Collection<String> getCacheNames(CacheOperationInvocationContext<?> context);
|
||||
protected abstract Collection<String> getCacheNames(@Nullable CacheOperationInvocationContext<?> context);
|
||||
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public abstract class AbstractFallbackCacheOperationSource implements CacheOpera
|
||||
* is not cacheable
|
||||
*/
|
||||
@Override
|
||||
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
|
||||
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
|
||||
if (method.getDeclaringClass() == Object.class) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.util.ObjectUtils;
|
||||
abstract class CacheOperationSourcePointcut extends StaticMethodMatcherPointcut implements Serializable {
|
||||
|
||||
@Override
|
||||
public boolean matches(Method method, Class<?> targetClass) {
|
||||
public boolean matches(Method method, @Nullable Class<?> targetClass) {
|
||||
CacheOperationSource cas = getCacheOperationSource();
|
||||
return (cas != null && !CollectionUtils.isEmpty(cas.getCacheOperations(method, targetClass)));
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,7 @@ public class CompositeCacheOperationSource implements CacheOperationSource, Seri
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
|
||||
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
|
||||
Collection<CacheOperation> ops = null;
|
||||
|
||||
for (CacheOperationSource source : this.cacheOperationSources) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
|
||||
@@ -76,7 +77,7 @@ public class NameMatchCacheOperationSource implements CacheOperationSource, Seri
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<CacheOperation> getCacheOperations(Method method, Class<?> targetClass) {
|
||||
public Collection<CacheOperation> getCacheOperations(Method method, @Nullable Class<?> targetClass) {
|
||||
// look for direct name match
|
||||
String methodName = method.getName();
|
||||
Collection<CacheOperation> ops = this.nameMap.get(methodName);
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A {@link CacheResolver} that forces the resolution to a configurable
|
||||
@@ -50,7 +51,7 @@ public class NamedCacheResolver extends AbstractCacheResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
||||
protected Collection<String> getCacheNames(@Nullable CacheOperationInvocationContext<?> context) {
|
||||
return this.cacheNames;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.Collection;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A simple {@link CacheResolver} that resolves the {@link Cache} instance(s)
|
||||
@@ -40,7 +41,7 @@ public class SimpleCacheResolver extends AbstractCacheResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<String> getCacheNames(CacheOperationInvocationContext<?> context) {
|
||||
protected Collection<String> getCacheNames(@Nullable CacheOperationInvocationContext<?> context) {
|
||||
return context.getOperation().getCacheNames();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,16 @@ public abstract class AbstractValueAdaptingCache implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper get(Object key) {
|
||||
@Nullable
|
||||
public ValueWrapper get(@Nullable Object key) {
|
||||
Object value = lookup(key);
|
||||
return toValueWrapper(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(Object key, Class<T> type) {
|
||||
@Nullable
|
||||
public <T> T get(@Nullable Object key, Class<T> type) {
|
||||
Object value = fromStoreValue(lookup(key));
|
||||
if (value != null && type != null && !type.isInstance(value)) {
|
||||
throw new IllegalStateException("Cached value is not of required type [" + type.getName() + "]: " + value);
|
||||
@@ -115,6 +117,7 @@ public abstract class AbstractValueAdaptingCache implements Cache {
|
||||
* @param storeValue the original value
|
||||
* @return the wrapped value
|
||||
*/
|
||||
@Nullable
|
||||
protected Cache.ValueWrapper toValueWrapper(Object storeValue) {
|
||||
return (storeValue != null ? new SimpleValueWrapper(fromStoreValue(storeValue)) : null);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.cache.support;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* A no operation {@link Cache} implementation suitable
|
||||
@@ -47,21 +48,21 @@ public class NoOpCache implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evict(Object key) {
|
||||
public void evict(@Nullable Object key) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper get(Object key) {
|
||||
public ValueWrapper get(@Nullable Object key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Object key, Class<T> type) {
|
||||
public <T> T get(@Nullable Object key, Class<T> type) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T get(Object key, Callable<T> valueLoader) {
|
||||
public <T> T get(@Nullable Object key, Callable<T> valueLoader) {
|
||||
try {
|
||||
return valueLoader.call();
|
||||
}
|
||||
@@ -81,11 +82,12 @@ public class NoOpCache implements Cache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void put(Object key, Object value) {
|
||||
public void put(@Nullable Object key, @Nullable Object value) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueWrapper putIfAbsent(Object key, Object value) {
|
||||
@Nullable
|
||||
public ValueWrapper putIfAbsent(@Nullable Object key, @Nullable Object value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ public class AnnotationConfigApplicationContext extends GenericApplicationContex
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void registerBean(String beanName, Class<T> beanClass, Supplier<T> supplier,
|
||||
public <T> void registerBean(@Nullable String beanName, @Nullable Class<T> beanClass, Supplier<T> supplier,
|
||||
BeanDefinitionCustomizer... customizers) {
|
||||
|
||||
this.reader.doRegisterBean(beanClass, supplier, beanName, null, customizers);
|
||||
|
||||
@@ -61,6 +61,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -201,7 +202,7 @@ public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
|
||||
this.beanClassLoader = beanClassLoader;
|
||||
if (!this.setMetadataReaderFactoryCalled) {
|
||||
this.metadataReaderFactory = new CachingMetadataReaderFactory(beanClassLoader);
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.context.weaving.DefaultContextLoadTimeWeaver;
|
||||
import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.instrument.classloading.LoadTimeWeaver;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* {@code @Configuration} class that registers a {@link LoadTimeWeaver} bean.
|
||||
@@ -64,7 +65,7 @@ public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoade
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
|
||||
this.beanClassLoader = beanClassLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.xml.AbstractBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
|
||||
import org.springframework.jmx.support.RegistrationPolicy;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,7 @@ class MBeanExportBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class);
|
||||
|
||||
// Mark as infrastructure bean and attach source location.
|
||||
|
||||
@@ -63,7 +63,7 @@ class MBeanServerBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) {
|
||||
String agentId = element.getAttribute(AGENT_ID_ATTRIBUTE);
|
||||
if (StringUtils.hasText(agentId)) {
|
||||
RootBeanDefinition bd = new RootBeanDefinition(MBeanServerFactoryBean.class);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -71,7 +72,7 @@ public abstract class AbstractApplicationEventMulticaster
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
@@ -123,7 +124,7 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void multicastEvent(final ApplicationEvent event, ResolvableType eventType) {
|
||||
public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) {
|
||||
ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event));
|
||||
for (final ApplicationListener<?> listener : getApplicationListeners(event, type)) {
|
||||
Executor executor = getTaskExecutor();
|
||||
|
||||
@@ -76,6 +76,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -461,7 +462,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
* @see ConfigurableEnvironment#merge(ConfigurableEnvironment)
|
||||
*/
|
||||
@Override
|
||||
public void setParent(ApplicationContext parent) {
|
||||
public void setParent(@Nullable ApplicationContext parent) {
|
||||
this.parent = parent;
|
||||
if (parent != null) {
|
||||
Environment parentEnvironment = parent.getEnvironment();
|
||||
@@ -844,7 +845,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
if (!beanFactory.hasEmbeddedValueResolver()) {
|
||||
beanFactory.addEmbeddedValueResolver(new StringValueResolver() {
|
||||
@Override
|
||||
public String resolveStringValue(String strVal) {
|
||||
public String resolveStringValue(@Nullable String strVal) {
|
||||
return getEnvironment().resolvePlaceholders(strVal);
|
||||
}
|
||||
});
|
||||
@@ -1081,7 +1082,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
|
||||
public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
|
||||
assertBeanFactoryActive();
|
||||
return getBeanFactory().getBean(name, requiredType);
|
||||
}
|
||||
@@ -1165,31 +1166,31 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBeanNamesForType(ResolvableType type) {
|
||||
public String[] getBeanNamesForType(@Nullable ResolvableType type) {
|
||||
assertBeanFactoryActive();
|
||||
return getBeanFactory().getBeanNamesForType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBeanNamesForType(Class<?> type) {
|
||||
public String[] getBeanNamesForType(@Nullable Class<?> type) {
|
||||
assertBeanFactoryActive();
|
||||
return getBeanFactory().getBeanNamesForType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
|
||||
public String[] getBeanNamesForType(@Nullable Class<?> type, boolean includeNonSingletons, boolean allowEagerInit) {
|
||||
assertBeanFactoryActive();
|
||||
return getBeanFactory().getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException {
|
||||
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type) throws BeansException {
|
||||
assertBeanFactoryActive();
|
||||
return getBeanFactory().getBeansOfType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
throws BeansException {
|
||||
|
||||
assertBeanFactoryActive();
|
||||
@@ -1249,12 +1250,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public String getMessage(String code, Object args[], String defaultMessage, Locale locale) {
|
||||
public String getMessage(String code, @Nullable Object args[], String defaultMessage, Locale locale) {
|
||||
return getMessageSource().getMessage(code, args, defaultMessage, locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String code, Object args[], Locale locale) throws NoSuchMessageException {
|
||||
public String getMessage(String code, @Nullable Object args[], Locale locale) throws NoSuchMessageException {
|
||||
return getMessageSource().getMessage(code, args, locale);
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
|
||||
|
||||
@Override
|
||||
public void setParentMessageSource(MessageSource parent) {
|
||||
public void setParentMessageSource(@Nullable MessageSource parent) {
|
||||
this.parentMessageSource = parent;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
|
||||
|
||||
@Override
|
||||
public final String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
|
||||
public final String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
|
||||
String msg = getMessageInternal(code, args, locale);
|
||||
if (msg != null) {
|
||||
return msg;
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
|
||||
public final String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException {
|
||||
String msg = getMessageInternal(code, args, locale);
|
||||
if (msg != null) {
|
||||
return msg;
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.context.HierarchicalMessageSource;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.context.NoSuchMessageException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Empty {@link MessageSource} that delegates all calls to the parent MessageSource.
|
||||
@@ -40,7 +41,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
|
||||
|
||||
|
||||
@Override
|
||||
public void setParentMessageSource(MessageSource parent) {
|
||||
public void setParentMessageSource(@Nullable MessageSource parent) {
|
||||
this.parentMessageSource = parent;
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
|
||||
|
||||
|
||||
@Override
|
||||
public String getMessage(String code, Object[] args, String defaultMessage, Locale locale) {
|
||||
public String getMessage(String code, @Nullable Object[] args, String defaultMessage, Locale locale) {
|
||||
if (this.parentMessageSource != null) {
|
||||
return this.parentMessageSource.getMessage(code, args, defaultMessage, locale);
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public class DelegatingMessageSource extends MessageSourceSupport implements Hie
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(String code, Object[] args, Locale locale) throws NoSuchMessageException {
|
||||
public String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException {
|
||||
if (this.parentMessageSource != null) {
|
||||
return this.parentMessageSource.getMessage(code, args, locale);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
|
||||
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory
|
||||
*/
|
||||
@Override
|
||||
public void setParent(ApplicationContext parent) {
|
||||
public void setParent(@Nullable ApplicationContext parent) {
|
||||
super.setParent(parent);
|
||||
this.beanFactory.setParentBeanFactory(getInternalParentBeanFactory());
|
||||
}
|
||||
@@ -238,7 +238,7 @@ public class GenericApplicationContext extends AbstractApplicationContext implem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
public void setClassLoader(@Nullable ClassLoader classLoader) {
|
||||
super.setClassLoader(classLoader);
|
||||
this.customClassLoader = true;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.core.env.PropertiesPropertySource;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
import org.springframework.core.env.PropertySources;
|
||||
import org.springframework.core.env.PropertySourcesPropertyResolver;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
@@ -166,7 +167,8 @@ public class PropertySourcesPlaceholderConfigurer extends PlaceholderConfigurerS
|
||||
|
||||
StringValueResolver valueResolver = new StringValueResolver() {
|
||||
@Override
|
||||
public String resolveStringValue(String strVal) {
|
||||
@Nullable
|
||||
public String resolveStringValue(@Nullable String strVal) {
|
||||
String resolved = (ignoreUnresolvablePlaceholders ?
|
||||
propertyResolver.resolvePlaceholders(strVal) :
|
||||
propertyResolver.resolveRequiredPlaceholders(strVal));
|
||||
|
||||
@@ -114,7 +114,7 @@ public class ResourceBundleMessageSource extends AbstractResourceBasedMessageSou
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class AspectJWeavingEnabler
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class DefaultContextLoadTimeWeaver implements LoadTimeWeaver, BeanClassLo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
LoadTimeWeaver serverSpecificLoadTimeWeaver = createServerSpecificLoadTimeWeaver(classLoader);
|
||||
if (serverSpecificLoadTimeWeaver != null) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.naming.NamingException;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -78,7 +79,7 @@ public class LocalStatelessSessionProxyFactoryBean extends LocalSlsbInvokerInter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import javax.naming.NamingException;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -92,7 +93,7 @@ public class SimpleRemoteStatelessSessionProxyFactoryBean extends SimpleRemoteSl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.format.Formatter;
|
||||
import org.springframework.format.FormatterRegistry;
|
||||
import org.springframework.format.Parser;
|
||||
import org.springframework.format.Printer;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.StringValueResolver;
|
||||
|
||||
@@ -145,7 +146,7 @@ public class FormattingConversionService extends GenericConversionService
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
if (source == null) {
|
||||
return "";
|
||||
}
|
||||
@@ -186,7 +187,7 @@ public class FormattingConversionService extends GenericConversionService
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
String text = (String) source;
|
||||
if (!StringUtils.hasText(text)) {
|
||||
return null;
|
||||
@@ -247,7 +248,7 @@ public class FormattingConversionService extends GenericConversionService
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
Annotation ann = sourceType.getAnnotation(this.annotationType);
|
||||
if (ann == null) {
|
||||
throw new IllegalStateException(
|
||||
@@ -301,7 +302,7 @@ public class FormattingConversionService extends GenericConversionService
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
public Object convert(@Nullable Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
|
||||
Annotation ann = targetType.getAnnotation(this.annotationType);
|
||||
if (ann == null) {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -231,7 +231,7 @@ public class MBeanClientInterceptor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
|
||||
this.beanClassLoader = beanClassLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.jmx.MBeanServerNotFoundException;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,7 @@ public class MBeanProxyFactoryBean extends MBeanClientInterceptor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ public class MBeanExporter extends MBeanRegistrationSupport implements MBeanExpo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.Properties;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -110,7 +111,7 @@ public class InterfaceBasedMBeanInfoAssembler extends AbstractConfigurableMBeanI
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
|
||||
this.beanClassLoader = beanClassLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -102,7 +103,7 @@ public class MBeanServerConnectionFactoryBean
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -178,7 +179,7 @@ public class JndiObjectFactoryBean extends JndiObjectLocator
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.jndi.JndiLocatorSupport;
|
||||
import org.springframework.jndi.TypeMismatchNamingException;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Simple JNDI-based implementation of Spring's
|
||||
@@ -106,7 +107,7 @@ public class SimpleJndiBeanFactory extends JndiLocatorSupport implements BeanFac
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
|
||||
public <T> T getBean(String name, @Nullable Class<T> requiredType) throws BeansException {
|
||||
try {
|
||||
if (isSingleton(name)) {
|
||||
return doGetSingleton(name, requiredType);
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.support.ArgumentConvertingMethodInvoker;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
@@ -46,7 +47,7 @@ public class MethodInvokingRunnable extends ArgumentConvertingMethodInvoker
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import bsh.EvalError;
|
||||
import bsh.Interpreter;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scripting.ScriptCompilationException;
|
||||
import org.springframework.scripting.ScriptEvaluator;
|
||||
import org.springframework.scripting.ScriptSource;
|
||||
@@ -56,18 +57,20 @@ public class BshScriptEvaluator implements ScriptEvaluator, BeanClassLoaderAware
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object evaluate(ScriptSource script) {
|
||||
return evaluate(script, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(ScriptSource script, Map<String, Object> arguments) {
|
||||
@Nullable
|
||||
public Object evaluate(ScriptSource script, @Nullable Map<String, Object> arguments) {
|
||||
try {
|
||||
Interpreter interpreter = new Interpreter();
|
||||
interpreter.setClassLoader(this.classLoader);
|
||||
|
||||
@@ -90,7 +90,7 @@ public class BshScriptFactory implements ScriptFactory, BeanClassLoaderAware {
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class BshScriptFactory implements ScriptFactory, BeanClassLoaderAware {
|
||||
* @see BshScriptUtils#createBshObject(String, Class[], ClassLoader)
|
||||
*/
|
||||
@Override
|
||||
public Object getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces)
|
||||
public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>... actualInterfaces)
|
||||
throws IOException, ScriptCompilationException {
|
||||
|
||||
Class<?> clazz;
|
||||
|
||||
@@ -104,7 +104,7 @@ class ScriptBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
|
||||
protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) {
|
||||
// Engine attribute only supported for <lang:std>
|
||||
String engine = element.getAttribute(ENGINE_ATTRIBUTE);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.codehaus.groovy.control.CompilerConfiguration;
|
||||
import org.codehaus.groovy.control.customizers.CompilationCustomizer;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scripting.ScriptCompilationException;
|
||||
import org.springframework.scripting.ScriptEvaluator;
|
||||
import org.springframework.scripting.ScriptSource;
|
||||
@@ -90,18 +91,20 @@ public class GroovyScriptEvaluator implements ScriptEvaluator, BeanClassLoaderAw
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object evaluate(ScriptSource script) {
|
||||
return evaluate(script, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(ScriptSource script, Map<String, Object> arguments) {
|
||||
@Nullable
|
||||
public Object evaluate(ScriptSource script, @Nullable Map<String, Object> arguments) {
|
||||
GroovyShell groovyShell = new GroovyShell(
|
||||
this.classLoader, new Binding(arguments), this.compilerConfiguration);
|
||||
try {
|
||||
|
||||
@@ -151,7 +151,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.groovyClassLoader = buildGroovyClassLoader(classLoader);
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class GroovyScriptFactory implements ScriptFactory, BeanFactoryAware, Bea
|
||||
* @see groovy.lang.GroovyClassLoader
|
||||
*/
|
||||
@Override
|
||||
public Object getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces)
|
||||
public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>... actualInterfaces)
|
||||
throws IOException, ScriptCompilationException {
|
||||
|
||||
synchronized (this.scriptClassMonitor) {
|
||||
|
||||
@@ -200,7 +200,7 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import javax.script.ScriptException;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scripting.ScriptCompilationException;
|
||||
import org.springframework.scripting.ScriptEvaluator;
|
||||
import org.springframework.scripting.ScriptSource;
|
||||
@@ -108,7 +109,7 @@ public class StandardScriptEvaluator implements ScriptEvaluator, BeanClassLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
if (this.scriptEngineManager == null) {
|
||||
this.scriptEngineManager = new ScriptEngineManager(classLoader);
|
||||
}
|
||||
@@ -121,7 +122,7 @@ public class StandardScriptEvaluator implements ScriptEvaluator, BeanClassLoader
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object evaluate(ScriptSource script, Map<String, Object> argumentBindings) {
|
||||
public Object evaluate(ScriptSource script, @Nullable Map<String, Object> argumentBindings) {
|
||||
ScriptEngine engine = getScriptEngine(script);
|
||||
try {
|
||||
if (CollectionUtils.isEmpty(argumentBindings)) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
|
||||
import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scripting.ScriptCompilationException;
|
||||
import org.springframework.scripting.ScriptFactory;
|
||||
import org.springframework.scripting.ScriptSource;
|
||||
@@ -107,7 +108,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader classLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader classLoader) {
|
||||
this.beanClassLoader = classLoader;
|
||||
}
|
||||
|
||||
@@ -131,7 +132,7 @@ public class StandardScriptFactory implements ScriptFactory, BeanClassLoaderAwar
|
||||
* Load and parse the script via JSR-223's ScriptEngine.
|
||||
*/
|
||||
@Override
|
||||
public Object getScriptedObject(ScriptSource scriptSource, Class<?>... actualInterfaces)
|
||||
public Object getScriptedObject(ScriptSource scriptSource, @Nullable Class<?>... actualInterfaces)
|
||||
throws IOException, ScriptCompilationException {
|
||||
|
||||
Object script = evaluateScript(scriptSource);
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ConcurrentModel extends ConcurrentHashMap<String, Object> implement
|
||||
* than for empty collections as is already done by JSTL tags.</emphasis>
|
||||
* @param attributeValue the model attribute value (never {@code null})
|
||||
*/
|
||||
public ConcurrentModel addAttribute(Object attributeValue) {
|
||||
public ConcurrentModel addAttribute(@Nullable Object attributeValue) {
|
||||
Assert.notNull(attributeValue, "Model object must not be null");
|
||||
if (attributeValue instanceof Collection && ((Collection<?>) attributeValue).isEmpty()) {
|
||||
return this;
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.springframework.ui;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Subclass of {@link ModelMap} that implements the {@link Model} interface.
|
||||
* Java 5 specific like the {@code Model} interface itself.
|
||||
@@ -35,13 +37,13 @@ import java.util.Map;
|
||||
public class ExtendedModelMap extends ModelMap implements Model {
|
||||
|
||||
@Override
|
||||
public ExtendedModelMap addAttribute(String attributeName, Object attributeValue) {
|
||||
public ExtendedModelMap addAttribute(String attributeName, @Nullable Object attributeValue) {
|
||||
super.addAttribute(attributeName, attributeValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtendedModelMap addAttribute(Object attributeValue) {
|
||||
public ExtendedModelMap addAttribute(@Nullable Object attributeValue) {
|
||||
super.addAttribute(attributeValue);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.ui.context.support;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.context.HierarchicalThemeSource;
|
||||
import org.springframework.ui.context.Theme;
|
||||
import org.springframework.ui.context.ThemeSource;
|
||||
@@ -37,7 +38,7 @@ public class DelegatingThemeSource implements HierarchicalThemeSource {
|
||||
|
||||
|
||||
@Override
|
||||
public void setParentThemeSource(ThemeSource parentThemeSource) {
|
||||
public void setParentThemeSource(@Nullable ThemeSource parentThemeSource) {
|
||||
this.parentThemeSource = parentThemeSource;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.BeanClassLoaderAware;
|
||||
import org.springframework.context.HierarchicalMessageSource;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.support.ResourceBundleMessageSource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.ui.context.HierarchicalThemeSource;
|
||||
import org.springframework.ui.context.Theme;
|
||||
import org.springframework.ui.context.ThemeSource;
|
||||
@@ -61,7 +62,7 @@ public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanC
|
||||
|
||||
|
||||
@Override
|
||||
public void setParentThemeSource(ThemeSource parent) {
|
||||
public void setParentThemeSource(@Nullable ThemeSource parent) {
|
||||
this.parentThemeSource = parent;
|
||||
|
||||
// Update existing Theme objects.
|
||||
@@ -115,7 +116,7 @@ public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanClassLoader(ClassLoader beanClassLoader) {
|
||||
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
|
||||
this.beanClassLoader = beanClassLoader;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.PropertyEditorRegistry;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -91,12 +92,12 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
||||
|
||||
|
||||
@Override
|
||||
public void reject(String errorCode, Object[] errorArgs, String defaultMessage) {
|
||||
public void reject(String errorCode, @Nullable Object[] errorArgs, String defaultMessage) {
|
||||
addError(new ObjectError(getObjectName(), resolveMessageCodes(errorCode), errorArgs, defaultMessage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage) {
|
||||
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
|
||||
if ("".equals(getNestedPath()) && !StringUtils.hasLength(field)) {
|
||||
// We're at the top of the nested object hierarchy,
|
||||
// so the present level is not a field but rather the top object.
|
||||
@@ -241,7 +242,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
||||
* @see #getActualFieldValue
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getFieldType(String field) {
|
||||
public Class<?> getFieldType(@Nullable String field) {
|
||||
Object value = getActualFieldValue(fixedField(field));
|
||||
if (value != null) {
|
||||
return value.getClass();
|
||||
@@ -289,7 +290,7 @@ public abstract class AbstractBindingResult extends AbstractErrors implements Bi
|
||||
* editor lookup facility, if available.
|
||||
*/
|
||||
@Override
|
||||
public PropertyEditor findEditor(String field, Class<?> valueType) {
|
||||
public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) {
|
||||
PropertyEditorRegistry editorRegistry = getPropertyEditorRegistry();
|
||||
if (editorRegistry != null) {
|
||||
Class<?> valueTypeToUse = valueType;
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -43,7 +44,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
|
||||
|
||||
@Override
|
||||
public void setNestedPath(String nestedPath) {
|
||||
public void setNestedPath(@Nullable String nestedPath) {
|
||||
doSetNestedPath(nestedPath);
|
||||
this.nestedPathStack.clear();
|
||||
}
|
||||
@@ -122,12 +123,12 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectValue(String field, String errorCode) {
|
||||
public void rejectValue(@Nullable String field, String errorCode) {
|
||||
rejectValue(field, errorCode, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectValue(String field, String errorCode, String defaultMessage) {
|
||||
public void rejectValue(@Nullable String field, String errorCode, String defaultMessage) {
|
||||
rejectValue(field, errorCode, null, defaultMessage);
|
||||
}
|
||||
|
||||
@@ -213,7 +214,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getFieldType(String field) {
|
||||
public Class<?> getFieldType(@Nullable String field) {
|
||||
Object value = getFieldValue(field);
|
||||
return (value != null ? value.getClass() : null);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
|
||||
* @see #getPropertyAccessor()
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getFieldType(String field) {
|
||||
public Class<?> getFieldType(@Nullable String field) {
|
||||
return getPropertyAccessor().getPropertyType(fixedField(field));
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractPropertyBindingResult extends AbstractBindingResul
|
||||
* if applicable.
|
||||
*/
|
||||
@Override
|
||||
public PropertyEditor findEditor(String field, Class<?> valueType) {
|
||||
public PropertyEditor findEditor(@Nullable String field, @Nullable Class<?> valueType) {
|
||||
Class<?> valueTypeForLookup = valueType;
|
||||
if (valueTypeForLookup == null) {
|
||||
valueTypeForLookup = getFieldType(field);
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.PropertyEditorRegistry;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -83,7 +84,7 @@ public class BindException extends Exception implements BindingResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNestedPath(String nestedPath) {
|
||||
public void setNestedPath(@Nullable String nestedPath) {
|
||||
this.bindingResult.setNestedPath(nestedPath);
|
||||
}
|
||||
|
||||
@@ -114,22 +115,22 @@ public class BindException extends Exception implements BindingResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reject(String errorCode, Object[] errorArgs, String defaultMessage) {
|
||||
public void reject(String errorCode, @Nullable Object[] errorArgs, String defaultMessage) {
|
||||
this.bindingResult.reject(errorCode, errorArgs, defaultMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectValue(String field, String errorCode) {
|
||||
public void rejectValue(@Nullable String field, String errorCode) {
|
||||
this.bindingResult.rejectValue(field, errorCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectValue(String field, String errorCode, String defaultMessage) {
|
||||
public void rejectValue(@Nullable String field, String errorCode, String defaultMessage) {
|
||||
this.bindingResult.rejectValue(field, errorCode, defaultMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectValue(String field, String errorCode, Object[] errorArgs, String defaultMessage) {
|
||||
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage) {
|
||||
this.bindingResult.rejectValue(field, errorCode, errorArgs, defaultMessage);
|
||||
}
|
||||
|
||||
@@ -220,7 +221,7 @@ public class BindException extends Exception implements BindingResult {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getFieldType(String field) {
|
||||
public Class<?> getFieldType(@Nullable String field) {
|
||||
return this.bindingResult.getFieldType(field);
|
||||
}
|
||||
|
||||
@@ -241,11 +242,13 @@ public class BindException extends Exception implements BindingResult {
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public PropertyEditor findEditor(String field, Class valueType) {
|
||||
@Nullable
|
||||
public PropertyEditor findEditor(@Nullable String field, @Nullable Class valueType) {
|
||||
return this.bindingResult.findEditor(field, valueType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PropertyEditorRegistry getPropertyEditorRegistry() {
|
||||
return this.bindingResult.getPropertyEditorRegistry();
|
||||
}
|
||||
|
||||
@@ -661,29 +661,29 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCustomEditor(Class<?> requiredType, String field, PropertyEditor propertyEditor) {
|
||||
public void registerCustomEditor(@Nullable Class<?> requiredType, @Nullable String field, PropertyEditor propertyEditor) {
|
||||
getPropertyEditorRegistry().registerCustomEditor(requiredType, field, propertyEditor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyEditor findCustomEditor(Class<?> requiredType, String propertyPath) {
|
||||
public PropertyEditor findCustomEditor(@Nullable Class<?> requiredType, @Nullable String propertyPath) {
|
||||
return getPropertyEditorRegistry().findCustomEditor(requiredType, propertyPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T convertIfNecessary(Object value, Class<T> requiredType) throws TypeMismatchException {
|
||||
public <T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType) throws TypeMismatchException {
|
||||
return getTypeConverter().convertIfNecessary(value, requiredType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T convertIfNecessary(Object value, Class<T> requiredType, MethodParameter methodParam)
|
||||
public <T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType, @Nullable MethodParameter methodParam)
|
||||
throws TypeMismatchException {
|
||||
|
||||
return getTypeConverter().convertIfNecessary(value, requiredType, methodParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T convertIfNecessary(Object value, Class<T> requiredType, Field field)
|
||||
public <T> T convertIfNecessary(Object value, @Nullable Class<T> requiredType, @Nullable Field field)
|
||||
throws TypeMismatchException {
|
||||
|
||||
return getTypeConverter().convertIfNecessary(value, requiredType, field);
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -146,7 +147,7 @@ public class DefaultMessageCodesResolver implements MessageCodesResolver, Serial
|
||||
* @return the list of codes
|
||||
*/
|
||||
@Override
|
||||
public String[] resolveMessageCodes(String errorCode, String objectName, String field, Class<?> fieldType) {
|
||||
public String[] resolveMessageCodes(String errorCode, String objectName, String field, @Nullable Class<?> fieldType) {
|
||||
Set<String> codeList = new LinkedHashSet<>();
|
||||
List<String> fieldList = new ArrayList<>();
|
||||
buildFieldList(field, fieldList);
|
||||
|
||||
@@ -167,7 +167,7 @@ public interface Errors {
|
||||
* @param defaultMessage fallback default message
|
||||
* @see #getNestedPath()
|
||||
*/
|
||||
void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, String defaultMessage);
|
||||
void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs, @Nullable String defaultMessage);
|
||||
|
||||
/**
|
||||
* Add all errors from the given {@code Errors} instance to this
|
||||
|
||||
@@ -32,6 +32,7 @@ import javax.validation.metadata.ConstraintDescriptor;
|
||||
import org.springframework.beans.NotReadablePropertyException;
|
||||
import org.springframework.context.MessageSourceResolvable;
|
||||
import org.springframework.context.support.DefaultMessageSourceResolvable;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.validation.Errors;
|
||||
@@ -93,14 +94,14 @@ public class SpringValidatorAdapter implements SmartValidator, javax.validation.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
public void validate(@Nullable Object target, Errors errors) {
|
||||
if (this.targetValidator != null) {
|
||||
processConstraintViolations(this.targetValidator.validate(target), errors);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors, Object... validationHints) {
|
||||
public void validate(@Nullable Object target, Errors errors, Object... validationHints) {
|
||||
if (this.targetValidator != null) {
|
||||
Set<Class<?>> groups = new LinkedHashSet<>();
|
||||
if (validationHints != null) {
|
||||
|
||||
Reference in New Issue
Block a user