Annotation Type Variant


  • @Target(TYPE)
    public @interface Variant
    Marks a class as a variant specification. The annotation processor adds Variant as an implemented interface. A spring configuration is generated. A variant specification is usually the root of a set of features. In the context of an application, this is usually a certain version (if there is, for instance, a standard and a professional version of the application) or a customer (if there is a specific manifestation of the application for each customer).

    Usage example:
     
     @Variant(features = #[Feature1])
     class Variant1 {
     }
      
    Leads to:
     
     @Configuration
     @ConditionalOnProperty(name = "variant", havingValue = "Variant1")
     public class Variant1 implements Variant {
       public final static String NAME = "Variant1";
       
       @Bean
       public String variant() {
         return Variant1.NAME;
       }
       
       @Bean
       @ConditionalOnProperty(name = "de.bmiag.tapir.variant.test.filter.data.Feature1.active", havingValue = "true", matchIfMissing = true)
       public Feature1 feature1() {
         return new Feature1();
       }
       
     }
      
    Since:
    2.0.0
    Author:
    Oliver Libutzki <[email protected]>
    See Also:
    Variant
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.Class<? extends Feature>[] features
      Returns the features which are available in this variant.
      java.lang.String name
      Returns the name of the variant.
      java.lang.String propertyName
      Returns the name of the property which determines the active variant.
    • Element Detail

      • name

        java.lang.String name
        Returns the name of the variant. If not specified explicitly the class name is used
        Returns:
        the name of the variant. If not specified explicitly the class name is used.
        Since:
        2.0.0
        Default:
        ""
      • features

        java.lang.Class<? extends Feature>[] features
        Returns the features which are available in this variant.
        Returns:
        the features which are available in this variant
        Since:
        2.0.0
        Default:
        {}
      • propertyName

        java.lang.String propertyName
        Returns the name of the property which determines the active variant. If not specified explicitly 'variant' is used
        Returns:
        the name of the property which determines the active variant. If not specified explicitly 'variant' is used
        Since:
        3.4.0
        Default:
        "variant"