Avoid defining nullability for non-relevant API

Defining nullability of some API like EnvironmentCapable
or ConditionContext causes issues in Spring Boot because
in the context where they are used, it is known for sure
they will return non-null values even if their API can in
other context return null values.

It is better in this case for both Java and Kotlin to
not define at all the nullabity of such API.

In practice, this is achieved by removing the package level
@NonNullApi annotation and adding it only on the
relevant classes.

Issue: SPR-15540
This commit is contained in:
Sebastien Deleuze 2017-05-31 22:45:31 +02:00
parent 1f28825f9d
commit b494c53b40
71 changed files with 146 additions and 16 deletions

View File

@ -21,6 +21,7 @@ import java.lang.annotation.Annotation;
import org.springframework.core.GenericTypeResolver; import org.springframework.core.GenericTypeResolver;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -32,6 +33,7 @@ import org.springframework.lang.Nullable;
* @since 3.1 * @since 3.1
* @param <A> annotation containing {@linkplain #getAdviceModeAttributeName() AdviceMode attribute} * @param <A> annotation containing {@linkplain #getAdviceModeAttributeName() AdviceMode attribute}
*/ */
@NonNullApi
public abstract class AdviceModeImportSelector<A extends Annotation> implements ImportSelector { public abstract class AdviceModeImportSelector<A extends Annotation> implements ImportSelector {
public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME = "mode"; public static final String DEFAULT_ADVICE_MODE_ATTRIBUTE_NAME = "mode";

View File

@ -30,6 +30,7 @@ import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.env.EnvironmentCapable; import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.StandardEnvironment;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -45,6 +46,7 @@ import org.springframework.util.Assert;
* @since 3.0 * @since 3.0
* @see AnnotationConfigApplicationContext#register * @see AnnotationConfigApplicationContext#register
*/ */
@NonNullApi
public class AnnotatedBeanDefinitionReader { public class AnnotatedBeanDefinitionReader {
private final BeanDefinitionRegistry registry; private final BeanDefinitionRegistry registry;

View File

@ -26,6 +26,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -60,6 +61,7 @@ import org.springframework.util.StringUtils;
* @see org.springframework.stereotype.Controller#value() * @see org.springframework.stereotype.Controller#value()
* @see javax.inject.Named#value() * @see javax.inject.Named#value()
*/ */
@NonNullApi
public class AnnotationBeanNameGenerator implements BeanNameGenerator { public class AnnotationBeanNameGenerator implements BeanNameGenerator {
private static final String COMPONENT_ANNOTATION_CLASSNAME = "org.springframework.stereotype.Component"; private static final String COMPONENT_ANNOTATION_CLASSNAME = "org.springframework.stereotype.Component";

View File

@ -23,6 +23,7 @@ import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.support.GenericApplicationContext; import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -50,6 +51,7 @@ import org.springframework.util.Assert;
* @see ClassPathBeanDefinitionScanner * @see ClassPathBeanDefinitionScanner
* @see org.springframework.context.support.GenericXmlApplicationContext * @see org.springframework.context.support.GenericXmlApplicationContext
*/ */
@NonNullApi
public class AnnotationConfigApplicationContext extends GenericApplicationContext implements AnnotationConfigRegistry { public class AnnotationConfigApplicationContext extends GenericApplicationContext implements AnnotationConfigRegistry {
private final AnnotatedBeanDefinitionReader reader; private final AnnotatedBeanDefinitionReader reader;

View File

@ -26,6 +26,7 @@ import org.springframework.beans.factory.parsing.BeanComponentDefinition;
import org.springframework.beans.factory.parsing.CompositeComponentDefinition; import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.xml.BeanDefinitionParser; import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext; import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.lang.NonNullApi;
/** /**
* Parser for the &lt;context:annotation-config/&gt; element. * Parser for the &lt;context:annotation-config/&gt; element.
@ -36,6 +37,7 @@ import org.springframework.beans.factory.xml.ParserContext;
* @since 2.5 * @since 2.5
* @see AnnotationConfigUtils * @see AnnotationConfigUtils
*/ */
@NonNullApi
public class AnnotationConfigBeanDefinitionParser implements BeanDefinitionParser { public class AnnotationConfigBeanDefinitionParser implements BeanDefinitionParser {
@Override @Override

View File

@ -16,6 +16,8 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.lang.NonNullApi;
/** /**
* Common interface for annotation config application contexts, * Common interface for annotation config application contexts,
* defining {@link #register} and {@link #scan} methods. * defining {@link #register} and {@link #scan} methods.
@ -23,6 +25,7 @@ package org.springframework.context.annotation;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.1 * @since 4.1
*/ */
@NonNullApi
public interface AnnotationConfigRegistry { public interface AnnotationConfigRegistry {
/** /**

View File

@ -37,6 +37,7 @@ import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -60,6 +61,7 @@ import org.springframework.util.ClassUtils;
* @see org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor * @see org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor
* @see org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor * @see org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor
*/ */
@NonNullApi
public class AnnotationConfigUtils { public class AnnotationConfigUtils {
/** /**

View File

@ -21,6 +21,7 @@ import java.lang.annotation.Annotation;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -36,6 +37,7 @@ import org.springframework.util.Assert;
* @since 2.5 * @since 2.5
* @see org.springframework.context.annotation.Scope * @see org.springframework.context.annotation.Scope
*/ */
@NonNullApi
public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver { public class AnnotationScopeMetadataResolver implements ScopeMetadataResolver {
private final ScopedProxyMode defaultProxyMode; private final ScopedProxyMode defaultProxyMode;

View File

@ -20,6 +20,7 @@ import org.springframework.aop.config.AopConfigUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* Registers an {@link org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator * Registers an {@link org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator
@ -31,6 +32,7 @@ import org.springframework.core.type.AnnotationMetadata;
* @since 3.1 * @since 3.1
* @see EnableAspectJAutoProxy * @see EnableAspectJAutoProxy
*/ */
@NonNullApi
class AspectJAutoProxyRegistrar implements ImportBeanDefinitionRegistrar { class AspectJAutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
/** /**

View File

@ -25,6 +25,7 @@ import org.springframework.aop.config.AopConfigUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* Registers an auto proxy creator against the current {@link BeanDefinitionRegistry} * Registers an auto proxy creator against the current {@link BeanDefinitionRegistry}
@ -35,6 +36,7 @@ import org.springframework.core.type.AnnotationMetadata;
* @since 3.1 * @since 3.1
* @see EnableAspectJAutoProxy * @see EnableAspectJAutoProxy
*/ */
@NonNullApi
public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar { public class AutoProxyRegistrar implements ImportBeanDefinitionRegistrar {
private final Log logger = LogFactory.getLog(getClass()); private final Log logger = LogFactory.getLog(getClass());

View File

@ -19,6 +19,7 @@ package org.springframework.context.annotation;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.lang.NonNullApi;
/** /**
* Utilities for processing {@link Bean}-annotated methods. * Utilities for processing {@link Bean}-annotated methods.
@ -27,6 +28,7 @@ import org.springframework.core.annotation.AnnotatedElementUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
class BeanAnnotationHelper { class BeanAnnotationHelper {
public static boolean isBeanAnnotated(Method method) { public static boolean isBeanAnnotated(Method method) {

View File

@ -19,6 +19,7 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.parsing.Problem; import org.springframework.beans.factory.parsing.Problem;
import org.springframework.beans.factory.parsing.ProblemReporter; import org.springframework.beans.factory.parsing.ProblemReporter;
import org.springframework.core.type.MethodMetadata; import org.springframework.core.type.MethodMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* Represents a {@link Configuration} class method marked with the * Represents a {@link Configuration} class method marked with the
@ -31,6 +32,7 @@ import org.springframework.core.type.MethodMetadata;
* @see ConfigurationClassParser * @see ConfigurationClassParser
* @see ConfigurationClassBeanDefinitionReader * @see ConfigurationClassBeanDefinitionReader
*/ */
@NonNullApi
final class BeanMethod extends ConfigurationMethod { final class BeanMethod extends ConfigurationMethod {
public BeanMethod(MethodMetadata metadata, ConfigurationClass configurationClass) { public BeanMethod(MethodMetadata metadata, ConfigurationClass configurationClass) {

View File

@ -31,6 +31,7 @@ import org.springframework.core.env.Environment;
import org.springframework.core.env.EnvironmentCapable; import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.PatternMatchUtils; import org.springframework.util.PatternMatchUtils;
@ -59,6 +60,7 @@ import org.springframework.util.PatternMatchUtils;
* @see org.springframework.stereotype.Service * @see org.springframework.stereotype.Service
* @see org.springframework.stereotype.Controller * @see org.springframework.stereotype.Controller
*/ */
@NonNullApi
public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateComponentProvider { public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateComponentProvider {
private final BeanDefinitionRegistry registry; private final BeanDefinitionRegistry registry;

View File

@ -51,6 +51,7 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.TypeFilter; import org.springframework.core.type.filter.TypeFilter;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -84,6 +85,7 @@ import org.springframework.util.ClassUtils;
* @see ScannedGenericBeanDefinition * @see ScannedGenericBeanDefinition
* @see CandidateComponentsIndex * @see CandidateComponentsIndex
*/ */
@NonNullApi
public class ClassPathScanningCandidateComponentProvider implements EnvironmentCapable, ResourceLoaderAware { public class ClassPathScanningCandidateComponentProvider implements EnvironmentCapable, ResourceLoaderAware {
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class"; static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";

View File

@ -65,6 +65,7 @@ import org.springframework.core.BridgeMethodResolver;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.jndi.support.SimpleJndiBeanFactory; import org.springframework.jndi.support.SimpleJndiBeanFactory;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
@ -139,6 +140,7 @@ import org.springframework.util.StringValueResolver;
* @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor * @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@NonNullApi
public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBeanPostProcessor public class CommonAnnotationBeanPostProcessor extends InitDestroyAnnotationBeanPostProcessor
implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable { implements InstantiationAwareBeanPostProcessor, BeanFactoryAware, Serializable {

View File

@ -38,6 +38,7 @@ import org.springframework.core.type.filter.AspectJTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.RegexPatternTypeFilter; import org.springframework.core.type.filter.RegexPatternTypeFilter;
import org.springframework.core.type.filter.TypeFilter; import org.springframework.core.type.filter.TypeFilter;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -52,6 +53,7 @@ import org.springframework.util.StringUtils;
* @see ClassPathBeanDefinitionScanner#scan(String...) * @see ClassPathBeanDefinitionScanner#scan(String...)
* @see ComponentScanBeanDefinitionParser * @see ComponentScanBeanDefinitionParser
*/ */
@NonNullApi
class ComponentScanAnnotationParser { class ComponentScanAnnotationParser {
private final Environment environment; private final Environment environment;

View File

@ -40,6 +40,7 @@ import org.springframework.core.type.filter.AspectJTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.RegexPatternTypeFilter; import org.springframework.core.type.filter.RegexPatternTypeFilter;
import org.springframework.core.type.filter.TypeFilter; import org.springframework.core.type.filter.TypeFilter;
import org.springframework.lang.NonNullApi;
import org.springframework.util.ReflectionUtils; import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -51,6 +52,7 @@ import org.springframework.util.StringUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 2.5 * @since 2.5
*/ */
@NonNullApi
public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser { public class ComponentScanBeanDefinitionParser implements BeanDefinitionParser {
private static final String BASE_PACKAGE_ATTRIBUTE = "base-package"; private static final String BASE_PACKAGE_ATTRIBUTE = "base-package";

View File

@ -18,6 +18,7 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* A single {@code condition} that must be {@linkplain #matches matched} in order * A single {@code condition} that must be {@linkplain #matches matched} in order
@ -39,6 +40,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata;
* @see ConditionContext * @see ConditionContext
*/ */
@FunctionalInterface @FunctionalInterface
@NonNullApi
public interface Condition { public interface Condition {
/** /**

View File

@ -20,7 +20,6 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
/** /**
* Context information for use by {@link Condition}s. * Context information for use by {@link Condition}s.
@ -35,7 +34,6 @@ public interface ConditionContext {
* should the condition match or {@code null} if the registry is not available. * should the condition match or {@code null} if the registry is not available.
* @return the registry or {@code null} * @return the registry or {@code null}
*/ */
@Nullable
BeanDefinitionRegistry getRegistry(); BeanDefinitionRegistry getRegistry();
/** /**
@ -44,7 +42,6 @@ public interface ConditionContext {
* is not available. * is not available.
* @return the bean factory or {@code null} * @return the bean factory or {@code null}
*/ */
@Nullable
ConfigurableListableBeanFactory getBeanFactory(); ConfigurableListableBeanFactory getBeanFactory();
/** /**
@ -52,7 +49,6 @@ public interface ConditionContext {
* or {@code null} if no environment is available. * or {@code null} if no environment is available.
* @return the environment or {@code null} * @return the environment or {@code null}
*/ */
@Nullable
Environment getEnvironment(); Environment getEnvironment();
/** /**
@ -60,7 +56,6 @@ public interface ConditionContext {
* if the resource loader cannot be obtained. * if the resource loader cannot be obtained.
* @return a resource loader or {@code null} * @return a resource loader or {@code null}
*/ */
@Nullable
ResourceLoader getResourceLoader(); ResourceLoader getResourceLoader();
/** /**
@ -68,7 +63,6 @@ public interface ConditionContext {
* classes or {@code null} if the default classloader should be used. * classes or {@code null} if the default classloader should be used.
* @return the class loader or {@code null} * @return the class loader or {@code null}
*/ */
@Nullable
ClassLoader getClassLoader(); ClassLoader getClassLoader();
} }

View File

@ -31,6 +31,7 @@ import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
@ -41,6 +42,7 @@ import org.springframework.util.MultiValueMap;
* @author Phillip Webb * @author Phillip Webb
* @since 4.0 * @since 4.0
*/ */
@NonNullApi
class ConditionEvaluator { class ConditionEvaluator {
private final ConditionContextImpl context; private final ConditionContextImpl context;

View File

@ -31,6 +31,7 @@ import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata; import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -47,6 +48,7 @@ import org.springframework.util.ClassUtils;
* @see BeanMethod * @see BeanMethod
* @see ConfigurationClassParser * @see ConfigurationClassParser
*/ */
@NonNullApi
final class ConfigurationClass { final class ConfigurationClass {
private final AnnotationMetadata metadata; private final AnnotationMetadata metadata;

View File

@ -50,6 +50,7 @@ import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.MethodMetadata; import org.springframework.core.type.MethodMetadata;
import org.springframework.lang.NonNullApi;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -67,6 +68,7 @@ import org.springframework.util.StringUtils;
* @since 3.0 * @since 3.0
* @see ConfigurationClassParser * @see ConfigurationClassParser
*/ */
@NonNullApi
class ConfigurationClassBeanDefinitionReader { class ConfigurationClassBeanDefinitionReader {
private static final Log logger = LogFactory.getLog(ConfigurationClassBeanDefinitionReader.class); private static final Log logger = LogFactory.getLog(ConfigurationClassBeanDefinitionReader.class);

View File

@ -49,6 +49,7 @@ import org.springframework.cglib.proxy.NoOp;
import org.springframework.cglib.transform.ClassEmitterTransformer; import org.springframework.cglib.transform.ClassEmitterTransformer;
import org.springframework.cglib.transform.TransformingClassGenerator; import org.springframework.cglib.transform.TransformingClassGenerator;
import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.objenesis.ObjenesisException; import org.springframework.objenesis.ObjenesisException;
import org.springframework.objenesis.SpringObjenesis; import org.springframework.objenesis.SpringObjenesis;
@ -72,6 +73,7 @@ import org.springframework.util.ReflectionUtils;
* @see #enhance * @see #enhance
* @see ConfigurationClassPostProcessor * @see ConfigurationClassPostProcessor
*/ */
@NonNullApi
class ConfigurationClassEnhancer { class ConfigurationClassEnhancer {
// The callbacks to use. Note that these callbacks must be stateless. // The callbacks to use. Note that these callbacks must be stateless.

View File

@ -72,6 +72,7 @@ import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.filter.AssignableTypeFilter; import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -100,6 +101,7 @@ import org.springframework.util.StringUtils;
* @since 3.0 * @since 3.0
* @see ConfigurationClassBeanDefinitionReader * @see ConfigurationClassBeanDefinitionReader
*/ */
@NonNullApi
class ConfigurationClassParser { class ConfigurationClassParser {
private static final PropertySourceFactory DEFAULT_PROPERTY_SOURCE_FACTORY = new DefaultPropertySourceFactory(); private static final PropertySourceFactory DEFAULT_PROPERTY_SOURCE_FACTORY = new DefaultPropertySourceFactory();

View File

@ -61,6 +61,7 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory; import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -85,6 +86,7 @@ import static org.springframework.context.annotation.AnnotationConfigUtils.*;
* @author Phillip Webb * @author Phillip Webb
* @since 3.0 * @since 3.0
*/ */
@NonNullApi
public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor, public class ConfigurationClassPostProcessor implements BeanDefinitionRegistryPostProcessor,
PriorityOrdered, ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware { PriorityOrdered, ResourceLoaderAware, BeanClassLoaderAware, EnvironmentAware {

View File

@ -35,6 +35,7 @@ import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.StandardAnnotationMetadata; import org.springframework.core.type.StandardAnnotationMetadata;
import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory; import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.lang.NonNullApi;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@ -44,6 +45,7 @@ import org.springframework.stereotype.Component;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
abstract class ConfigurationClassUtils { abstract class ConfigurationClassUtils {
private static final String CONFIGURATION_CLASS_FULL = "full"; private static final String CONFIGURATION_CLASS_FULL = "full";

View File

@ -16,6 +16,8 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.lang.NonNullApi;
/** /**
* A {@link Condition} that offers more fine-grained control when used with * A {@link Condition} that offers more fine-grained control when used with
* {@code @Configuration}. Allows certain {@link Condition}s to adapt when they match * {@code @Configuration}. Allows certain {@link Condition}s to adapt when they match
@ -27,6 +29,7 @@ package org.springframework.context.annotation;
* @since 4.0 * @since 4.0
* @see Configuration * @see Configuration
*/ */
@NonNullApi
public interface ConfigurationCondition extends Condition { public interface ConfigurationCondition extends Condition {
/** /**

View File

@ -19,11 +19,13 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.parsing.Location; import org.springframework.beans.factory.parsing.Location;
import org.springframework.beans.factory.parsing.ProblemReporter; import org.springframework.beans.factory.parsing.ProblemReporter;
import org.springframework.core.type.MethodMetadata; import org.springframework.core.type.MethodMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
abstract class ConfigurationMethod { abstract class ConfigurationMethod {
protected final MethodMetadata metadata; protected final MethodMetadata metadata;

View File

@ -16,6 +16,8 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.lang.NonNullApi;
/** /**
* Marker subclass of {@link IllegalStateException}, allowing for explicit * Marker subclass of {@link IllegalStateException}, allowing for explicit
* catch clauses in calling code. * catch clauses in calling code.
@ -24,6 +26,7 @@ package org.springframework.context.annotation;
* @since 3.1 * @since 3.1
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@NonNullApi
class ConflictingBeanDefinitionException extends IllegalStateException { class ConflictingBeanDefinitionException extends IllegalStateException {
public ConflictingBeanDefinitionException(String message) { public ConflictingBeanDefinitionException(String message) {

View File

@ -27,6 +27,7 @@ import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.core.annotation.AnnotationUtils; import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -38,6 +39,7 @@ import org.springframework.util.Assert;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.0 * @since 4.0
*/ */
@NonNullApi
public class ContextAnnotationAutowireCandidateResolver extends QualifierAnnotationAutowireCandidateResolver { public class ContextAnnotationAutowireCandidateResolver extends QualifierAnnotationAutowireCandidateResolver {
@Override @Override

View File

@ -16,6 +16,8 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.lang.NonNullApi;
/** /**
* A variation of {@link ImportSelector} that runs after all {@code @Configuration} beans * A variation of {@link ImportSelector} that runs after all {@code @Configuration} beans
* have been processed. This type of selector can be particularly useful when the selected * have been processed. This type of selector can be particularly useful when the selected
@ -28,6 +30,7 @@ package org.springframework.context.annotation;
* @author Phillip Webb * @author Phillip Webb
* @since 4.0 * @since 4.0
*/ */
@NonNullApi
public interface DeferredImportSelector extends ImportSelector { public interface DeferredImportSelector extends ImportSelector {
} }

View File

@ -18,6 +18,7 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.Aware; import org.springframework.beans.factory.Aware;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* Interface to be implemented by any @{@link Configuration} class that wishes * Interface to be implemented by any @{@link Configuration} class that wishes
@ -28,6 +29,7 @@ import org.springframework.core.type.AnnotationMetadata;
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
public interface ImportAware extends Aware { public interface ImportAware extends Aware {
/** /**

View File

@ -19,6 +19,7 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* Interface to be implemented by types that register additional bean definitions when * Interface to be implemented by types that register additional bean definitions when
@ -47,6 +48,7 @@ import org.springframework.core.type.AnnotationMetadata;
* @see ImportSelector * @see ImportSelector
* @see Configuration * @see Configuration
*/ */
@NonNullApi
public interface ImportBeanDefinitionRegistrar { public interface ImportBeanDefinitionRegistrar {
/** /**

View File

@ -17,11 +17,13 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Phil Webb * @author Phil Webb
*/ */
@NonNullApi
interface ImportRegistry { interface ImportRegistry {
AnnotationMetadata getImportingClassFor(String importedClass); AnnotationMetadata getImportingClassFor(String importedClass);

View File

@ -17,6 +17,7 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.lang.NonNullApi;
/** /**
* Interface to be implemented by types that determine which @{@link Configuration} * Interface to be implemented by types that determine which @{@link Configuration}
@ -45,6 +46,7 @@ import org.springframework.core.type.AnnotationMetadata;
* @see ImportBeanDefinitionRegistrar * @see ImportBeanDefinitionRegistrar
* @see Configuration * @see Configuration
*/ */
@NonNullApi
public interface ImportSelector { public interface ImportSelector {
/** /**

View File

@ -22,6 +22,7 @@ import java.util.Set;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.lang.NonNullApi;
/** /**
* Simple {@link ScopeMetadataResolver} implementation that follows JSR-330 scoping rules: * Simple {@link ScopeMetadataResolver} implementation that follows JSR-330 scoping rules:
@ -39,6 +40,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
* @see ClassPathBeanDefinitionScanner#setScopeMetadataResolver * @see ClassPathBeanDefinitionScanner#setScopeMetadataResolver
* @see AnnotatedBeanDefinitionReader#setScopeMetadataResolver * @see AnnotatedBeanDefinitionReader#setScopeMetadataResolver
*/ */
@NonNullApi
public class Jsr330ScopeMetadataResolver implements ScopeMetadataResolver { public class Jsr330ScopeMetadataResolver implements ScopeMetadataResolver {
private final Map<String, String> scopeMap = new HashMap<>(); private final Map<String, String> scopeMap = new HashMap<>();

View File

@ -26,6 +26,7 @@ import org.springframework.context.weaving.DefaultContextLoadTimeWeaver;
import org.springframework.core.annotation.AnnotationAttributes; import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.instrument.classloading.LoadTimeWeaver; import org.springframework.instrument.classloading.LoadTimeWeaver;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -41,6 +42,7 @@ import org.springframework.lang.Nullable;
* @see ConfigurableApplicationContext#LOAD_TIME_WEAVER_BEAN_NAME * @see ConfigurableApplicationContext#LOAD_TIME_WEAVER_BEAN_NAME
*/ */
@Configuration @Configuration
@NonNullApi
public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoaderAware { public class LoadTimeWeavingConfiguration implements ImportAware, BeanClassLoaderAware {
private AnnotationAttributes enableLTW; private AnnotationAttributes enableLTW;

View File

@ -17,6 +17,7 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.instrument.classloading.LoadTimeWeaver; import org.springframework.instrument.classloading.LoadTimeWeaver;
import org.springframework.lang.NonNullApi;
/** /**
* Interface to be implemented by * Interface to be implemented by
@ -33,6 +34,7 @@ import org.springframework.instrument.classloading.LoadTimeWeaver;
* @see LoadTimeWeavingConfiguration * @see LoadTimeWeavingConfiguration
* @see EnableLoadTimeWeaving * @see EnableLoadTimeWeaving
*/ */
@NonNullApi
public interface LoadTimeWeavingConfigurer { public interface LoadTimeWeavingConfigurer {
/** /**

View File

@ -32,6 +32,7 @@ import org.springframework.jmx.export.annotation.AnnotationMBeanExporter;
import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean; import org.springframework.jmx.support.WebSphereMBeanServerFactoryBean;
import org.springframework.jndi.JndiLocatorDelegate; import org.springframework.jndi.JndiLocatorDelegate;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -48,6 +49,7 @@ import org.springframework.util.StringUtils;
* @see EnableMBeanExport * @see EnableMBeanExport
*/ */
@Configuration @Configuration
@NonNullApi
public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, BeanFactoryAware { public class MBeanExportConfiguration implements ImportAware, EnvironmentAware, BeanFactoryAware {
private static final String MBEAN_EXPORTER_BEAN_NAME = "mbeanExporter"; private static final String MBEAN_EXPORTER_BEAN_NAME = "mbeanExporter";

View File

@ -26,6 +26,7 @@ import org.springframework.context.EnvironmentAware;
import org.springframework.context.ResourceLoaderAware; import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.NonNullApi;
/** /**
* Common delegate code for the handling of parser strategies, e.g. * Common delegate code for the handling of parser strategies, e.g.
@ -34,6 +35,7 @@ import org.springframework.core.io.ResourceLoader;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 4.3.3 * @since 4.3.3
*/ */
@NonNullApi
abstract class ParserStrategyUtils { abstract class ParserStrategyUtils {
/** /**

View File

@ -22,6 +22,7 @@ import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.core.type.AnnotationMetadata; import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.MethodMetadata; import org.springframework.core.type.MethodMetadata;
import org.springframework.core.type.classreading.MetadataReader; import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -45,6 +46,7 @@ import org.springframework.util.Assert;
* @see AnnotatedGenericBeanDefinition * @see AnnotatedGenericBeanDefinition
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@NonNullApi
public class ScannedGenericBeanDefinition extends GenericBeanDefinition implements AnnotatedBeanDefinition { public class ScannedGenericBeanDefinition extends GenericBeanDefinition implements AnnotatedBeanDefinition {
private final AnnotationMetadata metadata; private final AnnotationMetadata metadata;

View File

@ -17,6 +17,7 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.lang.NonNullApi;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
@ -32,6 +33,7 @@ import org.springframework.util.Assert;
* @see ScopeMetadataResolver * @see ScopeMetadataResolver
* @see ScopedProxyMode * @see ScopedProxyMode
*/ */
@NonNullApi
public class ScopeMetadata { public class ScopeMetadata {
private String scopeName = BeanDefinition.SCOPE_SINGLETON; private String scopeName = BeanDefinition.SCOPE_SINGLETON;

View File

@ -17,6 +17,7 @@
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.lang.NonNullApi;
/** /**
* Strategy interface for resolving the scope of bean definitions. * Strategy interface for resolving the scope of bean definitions.
@ -26,6 +27,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
* @see org.springframework.context.annotation.Scope * @see org.springframework.context.annotation.Scope
*/ */
@FunctionalInterface @FunctionalInterface
@NonNullApi
public interface ScopeMetadataResolver { public interface ScopeMetadataResolver {
/** /**

View File

@ -19,6 +19,7 @@ package org.springframework.context.annotation;
import org.springframework.aop.scope.ScopedProxyUtils; import org.springframework.aop.scope.ScopedProxyUtils;
import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.lang.NonNullApi;
/** /**
* Delegate factory class used to just introduce an AOP framework dependency * Delegate factory class used to just introduce an AOP framework dependency
@ -28,6 +29,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
* @since 3.0 * @since 3.0
* @see org.springframework.aop.scope.ScopedProxyUtils#createScopedProxy * @see org.springframework.aop.scope.ScopedProxyUtils#createScopedProxy
*/ */
@NonNullApi
class ScopedProxyCreator { class ScopedProxyCreator {
public static BeanDefinitionHolder createScopedProxy( public static BeanDefinitionHolder createScopedProxy(

View File

@ -3,7 +3,4 @@
* annotations, component-scanning, and Java-based metadata for creating * annotations, component-scanning, and Java-based metadata for creating
* Spring-managed objects. * Spring-managed objects.
*/ */
@NonNullApi
package org.springframework.context.annotation; package org.springframework.context.annotation;
import org.springframework.lang.NonNullApi;

View File

@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.core.SpringProperties; import org.springframework.core.SpringProperties;
import org.springframework.core.convert.support.ConfigurableConversionService; import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -51,6 +52,7 @@ import org.springframework.util.StringUtils;
* @see ConfigurableEnvironment * @see ConfigurableEnvironment
* @see StandardEnvironment * @see StandardEnvironment
*/ */
@NonNullApi
public abstract class AbstractEnvironment implements ConfigurableEnvironment { public abstract class AbstractEnvironment implements ConfigurableEnvironment {
/** /**

View File

@ -25,6 +25,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.ConfigurableConversionService; import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
@ -38,6 +39,7 @@ import org.springframework.util.SystemPropertyUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
public abstract class AbstractPropertyResolver implements ConfigurablePropertyResolver { public abstract class AbstractPropertyResolver implements ConfigurablePropertyResolver {
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());

View File

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -33,6 +34,7 @@ import org.springframework.lang.Nullable;
* @since 3.1 * @since 3.1
* @see SimpleCommandLineArgsParser * @see SimpleCommandLineArgsParser
*/ */
@NonNullApi
class CommandLineArgs { class CommandLineArgs {
private final Map<String, List<String>> optionArgs = new HashMap<>(); private final Map<String, List<String>> optionArgs = new HashMap<>();

View File

@ -19,6 +19,7 @@ package org.springframework.core.env;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -204,6 +205,7 @@ import org.springframework.util.StringUtils;
* @see SimpleCommandLinePropertySource * @see SimpleCommandLinePropertySource
* @see JOptCommandLinePropertySource * @see JOptCommandLinePropertySource
*/ */
@NonNullApi
public abstract class CommandLinePropertySource<T> extends EnumerablePropertySource<T> { public abstract class CommandLinePropertySource<T> extends EnumerablePropertySource<T> {
/** The default name given to {@link CommandLinePropertySource} instances: {@value} */ /** The default name given to {@link CommandLinePropertySource} instances: {@value} */

View File

@ -23,6 +23,7 @@ import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.springframework.lang.NonNullApi;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -39,6 +40,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb * @author Phillip Webb
* @since 3.1.1 * @since 3.1.1
*/ */
@NonNullApi
public class CompositePropertySource extends EnumerablePropertySource<Object> { public class CompositePropertySource extends EnumerablePropertySource<Object> {
private final Set<PropertySource<?>> propertySources = new LinkedHashSet<>(); private final Set<PropertySource<?>> propertySources = new LinkedHashSet<>();

View File

@ -18,6 +18,8 @@ package org.springframework.core.env;
import java.util.Map; import java.util.Map;
import org.springframework.lang.NonNullApi;
/** /**
* Configuration interface to be implemented by most if not all {@link Environment} types. * Configuration interface to be implemented by most if not all {@link Environment} types.
* Provides facilities for setting active and default profiles and manipulating underlying * Provides facilities for setting active and default profiles and manipulating underlying
@ -69,6 +71,7 @@ import java.util.Map;
* @see StandardEnvironment * @see StandardEnvironment
* @see org.springframework.context.ConfigurableApplicationContext#getEnvironment * @see org.springframework.context.ConfigurableApplicationContext#getEnvironment
*/ */
@NonNullApi
public interface ConfigurableEnvironment extends Environment, ConfigurablePropertyResolver { public interface ConfigurableEnvironment extends Environment, ConfigurablePropertyResolver {
/** /**

View File

@ -17,6 +17,7 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.core.convert.support.ConfigurableConversionService; import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -28,6 +29,7 @@ import org.springframework.lang.Nullable;
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
public interface ConfigurablePropertyResolver extends PropertyResolver { public interface ConfigurablePropertyResolver extends PropertyResolver {
/** /**

View File

@ -16,6 +16,7 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
/** /**
@ -41,6 +42,7 @@ import org.springframework.util.ObjectUtils;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
public abstract class EnumerablePropertySource<T> extends PropertySource<T> { public abstract class EnumerablePropertySource<T> extends PropertySource<T> {
public EnumerablePropertySource(String name, T source) { public EnumerablePropertySource(String name, T source) {

View File

@ -16,6 +16,8 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
/** /**
* Interface representing the environment in which the current application is running. * Interface representing the environment in which the current application is running.
* Models two key aspects of the application environment: <em>profiles</em> and * Models two key aspects of the application environment: <em>profiles</em> and
@ -68,6 +70,7 @@ package org.springframework.core.env;
* @see org.springframework.context.ConfigurableApplicationContext#setEnvironment * @see org.springframework.context.ConfigurableApplicationContext#setEnvironment
* @see org.springframework.context.support.AbstractApplicationContext#createEnvironment * @see org.springframework.context.support.AbstractApplicationContext#createEnvironment
*/ */
@NonNullApi
public interface Environment extends PropertyResolver { public interface Environment extends PropertyResolver {
/** /**

View File

@ -16,8 +16,6 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.Nullable;
/** /**
* Interface indicating a component that contains and exposes an {@link Environment} reference. * Interface indicating a component that contains and exposes an {@link Environment} reference.
* *
@ -46,7 +44,6 @@ public interface EnvironmentCapable {
* Return the {@link Environment} associated with this component * Return the {@link Environment} associated with this component
* (may be {@code null} or a default environment). * (may be {@code null} or a default environment).
*/ */
@Nullable
Environment getEnvironment(); Environment getEnvironment();
} }

View File

@ -23,6 +23,8 @@ import java.util.List;
import joptsimple.OptionSet; import joptsimple.OptionSet;
import joptsimple.OptionSpec; import joptsimple.OptionSpec;
import org.springframework.lang.NonNullApi;
/** /**
* {@link CommandLinePropertySource} implementation backed by a JOpt {@link OptionSet}. * {@link CommandLinePropertySource} implementation backed by a JOpt {@link OptionSet}.
* *
@ -54,6 +56,7 @@ import joptsimple.OptionSpec;
* @see joptsimple.OptionParser * @see joptsimple.OptionParser
* @see joptsimple.OptionSet * @see joptsimple.OptionSet
*/ */
@NonNullApi
public class JOptCommandLinePropertySource extends CommandLinePropertySource<OptionSet> { public class JOptCommandLinePropertySource extends CommandLinePropertySource<OptionSet> {
/** /**

View File

@ -18,6 +18,7 @@ package org.springframework.core.env;
import java.util.Map; import java.util.Map;
import org.springframework.lang.NonNullApi;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -28,6 +29,7 @@ import org.springframework.util.StringUtils;
* @since 3.1 * @since 3.1
* @see PropertiesPropertySource * @see PropertiesPropertySource
*/ */
@NonNullApi
public class MapPropertySource extends EnumerablePropertySource<Map<String, Object>> { public class MapPropertySource extends EnumerablePropertySource<Map<String, Object>> {
public MapPropertySource(String name, Map<String, Object> source) { public MapPropertySource(String name, Map<String, Object> source) {

View File

@ -19,6 +19,8 @@ package org.springframework.core.env;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.springframework.lang.NonNullApi;
/** /**
* Exception thrown when required properties are not found. * Exception thrown when required properties are not found.
* *
@ -29,6 +31,7 @@ import java.util.Set;
* @see org.springframework.context.support.AbstractApplicationContext#prepareRefresh() * @see org.springframework.context.support.AbstractApplicationContext#prepareRefresh()
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
@NonNullApi
public class MissingRequiredPropertiesException extends IllegalStateException { public class MissingRequiredPropertiesException extends IllegalStateException {
private final Set<String> missingRequiredProperties = new LinkedHashSet<>(); private final Set<String> missingRequiredProperties = new LinkedHashSet<>();

View File

@ -23,6 +23,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -40,6 +41,7 @@ import org.springframework.util.StringUtils;
* @since 3.1 * @since 3.1
* @see PropertySourcesPropertyResolver * @see PropertySourcesPropertyResolver
*/ */
@NonNullApi
public class MutablePropertySources implements PropertySources { public class MutablePropertySources implements PropertySources {
private final Log logger; private final Log logger;

View File

@ -19,6 +19,8 @@ package org.springframework.core.env;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import org.springframework.lang.NonNullApi;
/** /**
* {@link PropertySource} implementation that extracts properties from a * {@link PropertySource} implementation that extracts properties from a
* {@link java.util.Properties} object. * {@link java.util.Properties} object.
@ -33,6 +35,7 @@ import java.util.Properties;
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
public class PropertiesPropertySource extends MapPropertySource { public class PropertiesPropertySource extends MapPropertySource {
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({"unchecked", "rawtypes"})

View File

@ -16,6 +16,7 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -27,6 +28,7 @@ import org.springframework.lang.Nullable;
* @see Environment * @see Environment
* @see PropertySourcesPropertyResolver * @see PropertySourcesPropertyResolver
*/ */
@NonNullApi
public interface PropertyResolver { public interface PropertyResolver {
/** /**

View File

@ -19,6 +19,7 @@ package org.springframework.core.env;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
@ -56,6 +57,7 @@ import org.springframework.util.ObjectUtils;
* @see MutablePropertySources * @see MutablePropertySources
* @see org.springframework.context.annotation.PropertySource * @see org.springframework.context.annotation.PropertySource
*/ */
@NonNullApi
public abstract class PropertySource<T> { public abstract class PropertySource<T> {
protected final Log logger = LogFactory.getLog(getClass()); protected final Log logger = LogFactory.getLog(getClass());

View File

@ -16,6 +16,7 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -24,6 +25,7 @@ import org.springframework.lang.Nullable;
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
public interface PropertySources extends Iterable<PropertySource<?>> { public interface PropertySources extends Iterable<PropertySource<?>> {
/** /**

View File

@ -16,6 +16,7 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
@ -29,6 +30,7 @@ import org.springframework.lang.Nullable;
* @see PropertySources * @see PropertySources
* @see AbstractEnvironment * @see AbstractEnvironment
*/ */
@NonNullApi
public class PropertySourcesPropertyResolver extends AbstractPropertyResolver { public class PropertySourcesPropertyResolver extends AbstractPropertyResolver {
private final PropertySources propertySources; private final PropertySources propertySources;

View File

@ -21,6 +21,8 @@ import java.util.Collections;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.lang.NonNullApi;
/** /**
* Read-only {@code Map<String, String>} implementation that is backed by system * Read-only {@code Map<String, String>} implementation that is backed by system
* properties or environment variables. * properties or environment variables.
@ -35,6 +37,7 @@ import java.util.Set;
* @author Chris Beams * @author Chris Beams
* @since 3.0 * @since 3.0
*/ */
@NonNullApi
abstract class ReadOnlySystemAttributesMap implements Map<String, String> { abstract class ReadOnlySystemAttributesMap implements Map<String, String> {
@Override @Override

View File

@ -16,6 +16,8 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
/** /**
* Parses a {@code String[]} of command line arguments in order to populate a * Parses a {@code String[]} of command line arguments in order to populate a
* {@link CommandLineArgs} object. * {@link CommandLineArgs} object.
@ -49,6 +51,7 @@ package org.springframework.core.env;
* @author Chris Beams * @author Chris Beams
* @since 3.1 * @since 3.1
*/ */
@NonNullApi
class SimpleCommandLineArgsParser { class SimpleCommandLineArgsParser {
/** /**

View File

@ -18,6 +18,8 @@ package org.springframework.core.env;
import java.util.List; import java.util.List;
import org.springframework.lang.NonNullApi;
/** /**
* {@link CommandLinePropertySource} implementation backed by a simple String array. * {@link CommandLinePropertySource} implementation backed by a simple String array.
* *
@ -75,6 +77,7 @@ import java.util.List;
* @see CommandLinePropertySource * @see CommandLinePropertySource
* @see JOptCommandLinePropertySource * @see JOptCommandLinePropertySource
*/ */
@NonNullApi
public class SimpleCommandLinePropertySource extends CommandLinePropertySource<CommandLineArgs> { public class SimpleCommandLinePropertySource extends CommandLinePropertySource<CommandLineArgs> {
/** /**

View File

@ -16,6 +16,8 @@
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;
/** /**
* {@link Environment} implementation suitable for use in 'standard' (i.e. non-web) * {@link Environment} implementation suitable for use in 'standard' (i.e. non-web)
* applications. * applications.
@ -51,6 +53,7 @@ package org.springframework.core.env;
* @see SystemEnvironmentPropertySource * @see SystemEnvironmentPropertySource
* @see org.springframework.web.context.support.StandardServletEnvironment * @see org.springframework.web.context.support.StandardServletEnvironment
*/ */
@NonNullApi
public class StandardEnvironment extends AbstractEnvironment { public class StandardEnvironment extends AbstractEnvironment {
/** System environment property source name: {@value} */ /** System environment property source name: {@value} */

View File

@ -18,6 +18,7 @@ package org.springframework.core.env;
import java.util.Map; import java.util.Map;
import org.springframework.lang.NonNullApi;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -63,6 +64,7 @@ import org.springframework.util.Assert;
* @see AbstractEnvironment#getSystemEnvironment() * @see AbstractEnvironment#getSystemEnvironment()
* @see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME * @see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
*/ */
@NonNullApi
public class SystemEnvironmentPropertySource extends MapPropertySource { public class SystemEnvironmentPropertySource extends MapPropertySource {
/** /**

View File

@ -2,7 +2,4 @@
* Spring's environment abstraction consisting of bean definition * Spring's environment abstraction consisting of bean definition
* profile and hierarchical property source support. * profile and hierarchical property source support.
*/ */
@NonNullApi
package org.springframework.core.env; package org.springframework.core.env;
import org.springframework.lang.NonNullApi;

View File

@ -23,7 +23,7 @@ import javax.annotation.meta.TypeQualifierDefault;
*/ */
@Documented @Documented
@Nonnull @Nonnull
@Target(ElementType.PACKAGE) @Target({ElementType.PACKAGE, ElementType.TYPE})
@TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) @TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface NonNullApi { public @interface NonNullApi {