Package io.micronaut.context.annotation
Annotation Interface Requires
@Documented
@Retention(RUNTIME)
@Target({PACKAGE,TYPE,ANNOTATION_TYPE,METHOD,FIELD})
@Repeatable(Requirements.class)
public @interface Requires
Expresses a requirement for a bean or
Configuration
.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Used to express an operation system family.static enum
Used to express a required SDK version. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass<?>
Expresses that the bean the given class should be available for the bean or configuration to load.Used in combination withbean()
to express that the given bean property should be set for the bean to load.Class<?>[]
Expresses that beans of the given types should be available for the bean or configuration to load.Class<?>[]
Expresses the given classes that should be present on the classpath for the bean or configuration to load.One ore more custom condition classes.Expresses the configurations that should be present for the bean or configuration to load.Class<? extends Annotation>[]
Expresses that the configuration requires entities annotated with the given annotations to be available to the application via package scanning.String[]
Expresses that the configuration will only load within the given environments.Class<?>[]
Expresses the given classes that should be missing from the classpath for the bean or configuration to load.Class[]
Expresses the given beans that should be missing from the classpath for the bean or configuration to load.String[]
Expresses the given class names should be missing from the classpath for the bean configuration to load.String[]
Expresses the given configurations that should be missing from the classpath for the bean or configuration to load.Expresses that the bean or configuration will only be configured if the given property is missing.String[]
Expresses that the configuration will not load within the given environments.Constraint a property to not equal the given value.Expresses the current operating system must not be one in the given list.Expresses the current operating system must be one in the given list.Used in combination withproperty()
to express the required pattern of the property.Expresses that the given property should be set for the bean to load.String[]
Expresses the given resources should exist for the bean configuration to load.Used to express an SDK requirement.Used in combination withproperty()
to express the required value of the property.Used in combination withsdk()
,configuration()
,classes()
orbeans()
to express a minimum version of the SDK, configuration or classes.
-
Element Details
-
env
String[] envExpresses that the configuration will only load within the given environments.- Returns:
- The names of the environments this configuration will load in
- Default:
- {}
-
notEnv
String[] notEnvExpresses that the configuration will not load within the given environments.- Returns:
- The names of the environments this configuration will not load in
- Default:
- {}
-
property
String propertyExpresses that the given property should be set for the bean to load.- Returns:
- The property that should be set.
- Default:
- ""
-
notEquals
String notEqualsConstraint a property to not equal the given value.- Returns:
- The value to not equal
- Default:
- ""
-
condition
One ore more custom condition classes.- Returns:
- The condition classes
- Default:
- io.micronaut.context.condition.TrueCondition.class
-
sdk
Requires.Sdk sdkUsed to express an SDK requirement. Typically used in combination withversion()
to specify a minimum version requirement.- Returns:
- The SDK required
- Default:
- MICRONAUT
-
configuration
String configurationExpresses the configurations that should be present for the bean or configuration to load.- Returns:
- The configurations
- Default:
- ""
-
value
String valueUsed in combination withproperty()
to express the required value of the property.- Returns:
- The required value
- Default:
- ""
-
defaultValue
String defaultValue- Returns:
- The default value if no value is specified
- Default:
- ""
-
pattern
String patternUsed in combination withproperty()
to express the required pattern of the property. The pattern will be evaluated withString.matches(String)
.- Returns:
- The required pattern
- Default:
- ""
-
version
String versionUsed in combination withsdk()
,configuration()
,classes()
orbeans()
to express a minimum version of the SDK, configuration or classes.- Returns:
- The minimum version
- Default:
- ""
-
classes
Class<?>[] classesExpresses the given classes that should be present on the classpath for the bean or configuration to load.- Returns:
- The classes
- Default:
- {}
-
entities
Class<? extends Annotation>[] entitiesExpresses that the configuration requires entities annotated with the given annotations to be available to the application via package scanning.- Returns:
- The classes
- Default:
- {}
-
beans
Class<?>[] beansExpresses that beans of the given types should be available for the bean or configuration to load.- Returns:
- The beans
- Default:
- {}
-
missing
Class<?>[] missingExpresses the given classes that should be missing from the classpath for the bean or configuration to load.- Returns:
- The classes
- Default:
- {}
-
missingClasses
Expresses the given class names should be missing from the classpath for the bean configuration to load.- Returns:
- The names of the classes that should be missing
- Default:
- {}
-
missingBeans
Class[] missingBeansExpresses the given beans that should be missing from the classpath for the bean or configuration to load.- Returns:
- The classes
- Default:
- {}
-
missingConfigurations
String[] missingConfigurationsExpresses the given configurations that should be missing from the classpath for the bean or configuration to load.- Returns:
- The classes
- Default:
- {}
-
missingProperty
String missingPropertyExpresses that the bean or configuration will only be configured if the given property is missing.- Returns:
- The property or properties that should be missing
- Default:
- ""
-
resources
String[] resourcesExpresses the given resources should exist for the bean configuration to load. Resources can be anything thatResourceResolver
can read, eg:file:/path/to/file.txt classpath:com/mycompany/file.txt
- Returns:
- The file paths
- Default:
- {}
-
os
Requires.Family[] osExpresses the current operating system must be one in the given list.- Returns:
- The os families
- Default:
- {}
-
notOs
Requires.Family[] notOsExpresses the current operating system must not be one in the given list.- Returns:
- The os families
- Default:
- {}
-
bean
Class<?> beanExpresses that the bean the given class should be available for the bean or configuration to load. Can be used in combination withbeanProperty()
to specify the required bean property- Returns:
- The configuration properties class
- Since:
- 3.4.0
- Default:
- void.class
-
beanProperty
String beanPropertyUsed in combination withbean()
to express that the given bean property should be set for the bean to load.- Returns:
- The configuration property that should be set.
- Since:
- 3.4.0
- Default:
- ""
-