Annotation Type 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
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.Class bean
      Expresses that the bean the given class should be available for the bean or configuration to load.
      java.lang.String beanProperty
      Used in combination with bean() to express that the given bean property should be set for the bean to load.
      java.lang.Class[] beans
      Expresses that beans of the given types should be available for the bean or configuration to load.
      java.lang.Class[] classes
      Expresses the given classes that should be present on the classpath for the bean or configuration to load.
      java.lang.Class<? extends Condition> condition
      One ore more custom condition classes.
      java.lang.String configuration
      Expresses the configurations that should be present for the bean or configuration to load.
      java.lang.String defaultValue  
      java.lang.Class<? extends java.lang.annotation.Annotation>[] entities
      Expresses that the configuration requires entities annotated with the given annotations to be available to the application via package scanning.
      java.lang.String[] env
      Expresses that the configuration will only load within the given environments.
      java.lang.Class[] missing
      Expresses the given classes that should be missing from the classpath for the bean or configuration to load.
      java.lang.Class[] missingBeans
      Expresses the given beans that should be missing from the classpath for the bean or configuration to load.
      java.lang.String[] missingClasses
      Expresses the given class names should be missing from the classpath for the bean configuration to load.
      java.lang.String[] missingConfigurations
      Expresses the given configurations that should be missing from the classpath for the bean or configuration to load.
      java.lang.String missingProperty
      Expresses that the bean or configuration will only be configured if the given property is missing.
      java.lang.String[] notEnv
      Expresses that the configuration will not load within the given environments.
      java.lang.String notEquals
      Constraint a property to not equal the given value.
      Requires.Family[] notOs
      Expresses the current operating system must not be one in the given list.
      Requires.Family[] os
      Expresses the current operating system must be one in the given list.
      java.lang.String pattern
      Used in combination with property() to express the required pattern of the property.
      java.lang.String property
      Expresses that the given property should be set for the bean to load.
      java.lang.String[] resources
      Expresses the given resources should exist for the bean configuration to load.
      Requires.Sdk sdk
      Used to express an SDK requirement.
      java.lang.String value
      Used in combination with property() to express the required value of the property.
      java.lang.String version
      Used in combination with sdk(), configuration(), classes() or beans() to express a minimum version of the SDK, configuration or classes.
    • Element Detail

      • env

        java.lang.String[] env
        Expresses that the configuration will only load within the given environments.
        Returns:
        The names of the environments this configuration will load in
        Default:
        {}
      • notEnv

        java.lang.String[] notEnv
        Expresses that the configuration will not load within the given environments.
        Returns:
        The names of the environments this configuration will not load in
        Default:
        {}
      • property

        java.lang.String property
        Expresses that the given property should be set for the bean to load.
        Returns:
        The property that should be set.
        Default:
        ""
      • notEquals

        java.lang.String notEquals
        Constraint a property to not equal the given value.
        Returns:
        The value to not equal
        Default:
        ""
      • condition

        @InstantiatedMember
        java.lang.Class<? extends Condition> condition
        One ore more custom condition classes.
        Returns:
        The condition classes
        Default:
        io.micronaut.context.condition.TrueCondition.class
      • sdk

        Requires.Sdk sdk
        Used to express an SDK requirement. Typically used in combination with version() to specify a minimum version requirement.
        Returns:
        The SDK required
        Default:
        io.micronaut.context.annotation.Requires.Sdk.MICRONAUT
      • configuration

        java.lang.String configuration
        Expresses the configurations that should be present for the bean or configuration to load.
        Returns:
        The configurations
        Default:
        ""
      • value

        java.lang.String value
        Used in combination with property() to express the required value of the property.
        Returns:
        The required value
        Default:
        ""
      • defaultValue

        java.lang.String defaultValue
        Returns:
        The default value if no value is specified
        Default:
        ""
      • pattern

        java.lang.String pattern
        Used in combination with property() to express the required pattern of the property. The pattern will be evaluated with String.matches(String).
        Returns:
        The required pattern
        Default:
        ""
      • version

        java.lang.String version
        Used in combination with sdk(), configuration(), classes() or beans() to express a minimum version of the SDK, configuration or classes.
        Returns:
        The minimum version
        Default:
        ""
      • classes

        java.lang.Class[] classes
        Expresses the given classes that should be present on the classpath for the bean or configuration to load.
        Returns:
        The classes
        Default:
        {}
      • entities

        java.lang.Class<? extends java.lang.annotation.Annotation>[] entities
        Expresses that the configuration requires entities annotated with the given annotations to be available to the application via package scanning.
        Returns:
        The classes
        Default:
        {}
      • beans

        java.lang.Class[] beans
        Expresses that beans of the given types should be available for the bean or configuration to load.
        Returns:
        The beans
        Default:
        {}
      • missing

        java.lang.Class[] missing
        Expresses the given classes that should be missing from the classpath for the bean or configuration to load.
        Returns:
        The classes
        Default:
        {}
      • missingClasses

        @AliasFor(member="missing")
        java.lang.String[] 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

        java.lang.Class[] missingBeans
        Expresses the given beans that should be missing from the classpath for the bean or configuration to load.
        Returns:
        The classes
        Default:
        {}
      • missingConfigurations

        java.lang.String[] missingConfigurations
        Expresses the given configurations that should be missing from the classpath for the bean or configuration to load.
        Returns:
        The classes
        Default:
        {}
      • missingProperty

        java.lang.String missingProperty
        Expresses 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

        java.lang.String[] resources
        Expresses the given resources should exist for the bean configuration to load. Resources can be anything that ResourceResolver can read, eg:
          file:/path/to/file.txt
          classpath:com/mycompany/file.txt
         
        Returns:
        The file paths
        Default:
        {}
      • os

        Requires.Family[] os
        Expresses the current operating system must be one in the given list.
        Returns:
        The os families
        Default:
        {}
      • notOs

        Requires.Family[] notOs
        Expresses the current operating system must not be one in the given list.
        Returns:
        The os families
        Default:
        {}
      • bean

        java.lang.Class bean
        Expresses that the bean the given class should be available for the bean or configuration to load. Can be used in combination with beanProperty() to specify the required bean property
        Returns:
        The configuration properties class
        Since:
        3.4.0
        Default:
        void.class
      • beanProperty

        java.lang.String beanProperty
        Used in combination with bean() 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:
        ""