Class AnnotationDescription.Builder

java.lang.Object
net.bytebuddy.description.annotation.AnnotationDescription.Builder
Enclosing interface:
AnnotationDescription

@Enhance public static class AnnotationDescription.Builder extends Object
A builder for pragmatically creating AnnotationDescription.
  • Field Details

    • annotationType

      private final TypeDescription annotationType
      The annotation type.
    • annotationValues

      private final Map<String,AnnotationValue<?,?>> annotationValues
      A mapping of annotation properties to their annotation values.
  • Constructor Details

    • Builder

      protected Builder(TypeDescription annotationType, Map<String,AnnotationValue<?,?>> annotationValues)
      Creates a builder for an annotation description.
      Parameters:
      annotationType - The annotation type.
      annotationValues - A mapping of annotation properties to their annotation values.
  • Method Details

    • ofType

      public static AnnotationDescription.Builder ofType(Class<? extends Annotation> annotationType)
      Creates a builder for creating an annotation of the given type.
      Parameters:
      annotationType - The annotation type.
      Returns:
      A builder for creating an annotation of the given type.
    • ofType

      public static AnnotationDescription.Builder ofType(TypeDescription annotationType)
      Creates a builder for creating an annotation of the given type.
      Parameters:
      annotationType - A description of the annotation type.
      Returns:
      A builder for creating an annotation of the given type.
    • define

      public AnnotationDescription.Builder define(String property, AnnotationValue<?,?> value)
      Returns a builder with the additional, given property.
      Parameters:
      property - The name of the property to define.
      value - An explicit description of the annotation value.
      Returns:
      A builder with the additional, given property.
    • define

      public AnnotationDescription.Builder define(String property, Enum<?> value)
      Returns a builder with the additional enumeration property.
      Parameters:
      property - The name of the property to define.
      value - The enumeration value to define.
      Returns:
      A builder with the additional enumeration property.
    • define

      public AnnotationDescription.Builder define(String property, TypeDescription enumerationType, String value)
      Returns a builder with the additional enumeration property.
      Parameters:
      property - The name of the property to define.
      enumerationType - The type of the enumeration.
      value - The enumeration value to define.
      Returns:
      A builder with the additional enumeration property.
    • define

      Returns a builder with the additional enumeration property.
      Parameters:
      property - The name of the property to define.
      value - A description of the enumeration value to define.
      Returns:
      A builder with the additional enumeration property.
    • define

      public AnnotationDescription.Builder define(String property, Annotation annotation)
      Returns a builder with the additional annotation property.
      Parameters:
      property - The name of the property to define.
      annotation - The annotation value to define.
      Returns:
      A builder with the additional annotation property.
    • define

      public AnnotationDescription.Builder define(String property, AnnotationDescription annotationDescription)
      Returns a builder with the additional annotation property.
      Parameters:
      property - The name of the property to define.
      annotationDescription - A description of the annotation value to define.
      Returns:
      A builder with the additional annotation property.
    • define

      public AnnotationDescription.Builder define(String property, Class<?> type)
      Returns a builder with the additional class property.
      Parameters:
      property - The name of the property to define.
      type - The class value to define.
      Returns:
      A builder with the additional class property.
    • define

      public AnnotationDescription.Builder define(String property, TypeDescription typeDescription)
      Returns a builder with the additional class property.
      Parameters:
      property - The name of the property to define.
      typeDescription - A description of the type to define as a property value.
      Returns:
      A builder with the additional class property.
    • defineEnumerationArray

      public <T extends Enum<?>> AnnotationDescription.Builder defineEnumerationArray(String property, Class<T> enumerationType, T... value)
      Returns a builder with the additional enumeration array property.
      Type Parameters:
      T - The enumeration type.
      Parameters:
      property - The name of the property to define.
      enumerationType - The type of the enumeration, i.e. the component type of the enumeration array.
      value - The enumeration values to be contained by the array.
      Returns:
      A builder with the additional class property.
    • defineEnumerationArray

      public AnnotationDescription.Builder defineEnumerationArray(String property, TypeDescription enumerationType, String... value)
      Returns a builder with the additional enumeration array property.
      Parameters:
      property - The name of the property to define.
      enumerationType - The type of the enumerations, i.e. is the component type of the enumeration array.
      value - The enumeration values to be contained by the array.
      Returns:
      A builder with the additional enumeration property.
    • defineEnumerationArray

      public AnnotationDescription.Builder defineEnumerationArray(String property, TypeDescription enumerationType, EnumerationDescription... value)
      Returns a builder with the additional enumeration array property.
      Parameters:
      property - The name of the property to define.
      enumerationType - The type of the enumerations, i.e. the component type of the enumeration array.
      value - Descriptions of the enumerations to be contained by the array.
      Returns:
      A builder with the additional enumeration property.
    • defineAnnotationArray

      public <T extends Annotation> AnnotationDescription.Builder defineAnnotationArray(String property, Class<T> annotationType, T... annotation)
      Returns a builder with the additional annotation array property.
      Type Parameters:
      T - The annotation type.
      Parameters:
      property - The name of the property to define.
      annotationType - The type of the annotations, i.e. the component type of the enumeration array.
      annotation - The annotation values to be contained by the array.
      Returns:
      A builder with the additional annotation property.
    • defineAnnotationArray

      public AnnotationDescription.Builder defineAnnotationArray(String property, TypeDescription annotationType, AnnotationDescription... annotationDescription)
      Returns a builder with the additional annotation array property.
      Parameters:
      property - The name of the property to define.
      annotationType - The type of the annotations, i.e. the component type of the enumeration array.
      annotationDescription - Descriptions of the annotation values to be contained by the array.
      Returns:
      A builder with the additional annotation property.
    • defineTypeArray

      public AnnotationDescription.Builder defineTypeArray(String property, Class<?>... type)
      Returns a builder with the additional type array property.
      Parameters:
      property - The name of the property to define.
      type - The types that should be contained by the array.
      Returns:
      A builder with the additional type array property.
    • defineTypeArray

      public AnnotationDescription.Builder defineTypeArray(String property, TypeDescription... typeDescription)
      Returns a builder with the additional type array property.
      Parameters:
      property - The name of the property to define.
      typeDescription - Descriptions of the types that should be contained by the array.
      Returns:
      A builder with the additional type array property.
    • define

      public AnnotationDescription.Builder define(String property, boolean value)
      Returns a builder with the additional boolean property.
      Parameters:
      property - The name of the property to define.
      value - The boolean value to define for the property.
      Returns:
      A builder with the additional boolean property.
    • define

      public AnnotationDescription.Builder define(String property, byte value)
      Returns a builder with the additional byte property.
      Parameters:
      property - The name of the property to define.
      value - The byte value to define for the property.
      Returns:
      A builder with the additional byte property.
    • define

      public AnnotationDescription.Builder define(String property, char value)
      Returns a builder with the additional char property.
      Parameters:
      property - The name of the property to define.
      value - The char value to define for the property.
      Returns:
      A builder with the additional char property.
    • define

      public AnnotationDescription.Builder define(String property, short value)
      Returns a builder with the additional short property.
      Parameters:
      property - The name of the property to define.
      value - The short value to define for the property.
      Returns:
      A builder with the additional short property.
    • define

      public AnnotationDescription.Builder define(String property, int value)
      Returns a builder with the additional int property.
      Parameters:
      property - The name of the property to define.
      value - The int value to define for the property.
      Returns:
      A builder with the additional int property.
    • define

      public AnnotationDescription.Builder define(String property, long value)
      Returns a builder with the additional long property.
      Parameters:
      property - The name of the property to define.
      value - The long value to define for the property.
      Returns:
      A builder with the additional long property.
    • define

      public AnnotationDescription.Builder define(String property, float value)
      Returns a builder with the additional float property.
      Parameters:
      property - The name of the property to define.
      value - The float value to define for the property.
      Returns:
      A builder with the additional float property.
    • define

      public AnnotationDescription.Builder define(String property, double value)
      Returns a builder with the additional double property.
      Parameters:
      property - The name of the property to define.
      value - The double value to define for the property.
      Returns:
      A builder with the additional double property.
    • define

      public AnnotationDescription.Builder define(String property, String value)
      Returns a builder with the additional String property.
      Parameters:
      property - The name of the property to define.
      value - The String value to define for the property.
      Returns:
      A builder with the additional String property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, boolean... value)
      Returns a builder with the additional boolean array property.
      Parameters:
      property - The name of the property to define.
      value - The boolean values to define for the property.
      Returns:
      A builder with the additional boolean array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, byte... value)
      Returns a builder with the additional byte array property.
      Parameters:
      property - The name of the property to define.
      value - The byte values to define for the property.
      Returns:
      A builder with the additional byte array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, char... value)
      Returns a builder with the additional char array property.
      Parameters:
      property - The name of the property to define.
      value - The char values to define for the property.
      Returns:
      A builder with the additional char array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, short... value)
      Returns a builder with the additional short array property.
      Parameters:
      property - The name of the property to define.
      value - The short values to define for the property.
      Returns:
      A builder with the additional short array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, int... value)
      Returns a builder with the additional int array property.
      Parameters:
      property - The name of the property to define.
      value - The int values to define for the property.
      Returns:
      A builder with the additional int array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, long... value)
      Returns a builder with the additional long array property.
      Parameters:
      property - The name of the property to define.
      value - The long values to define for the property.
      Returns:
      A builder with the additional long array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, float... value)
      Returns a builder with the additional float array property.
      Parameters:
      property - The name of the property to define.
      value - The float values to define for the property.
      Returns:
      A builder with the additional float array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, double... value)
      Returns a builder with the additional double array property.
      Parameters:
      property - The name of the property to define.
      value - The double values to define for the property.
      Returns:
      A builder with the additional double array property.
    • defineArray

      public AnnotationDescription.Builder defineArray(String property, String... value)
      Returns a builder with the additional String array property.
      Parameters:
      property - The name of the property to define.
      value - The String array value to define for the property.
      Returns:
      A builder with the additional String array property.
    • build

      public AnnotationDescription build()
      Creates an annotation description for the values that were defined for this builder. It is validated that all properties are defined if no default value is set for an annotation property.
      Returns:
      An appropriate annotation description.
    • build

      public AnnotationDescription build(boolean validated)
      Creates an annotation description for the values that were defined for this builder.
      Parameters:
      validated - true if the annotation description should be validated for having included all values.
      Returns:
      An appropriate annotation description.