Class AnnotationDescription.Builder
- java.lang.Object
-
- net.bytebuddy.description.annotation.AnnotationDescription.Builder
-
- Enclosing interface:
- AnnotationDescription
@Enhance public static class AnnotationDescription.Builder extends java.lang.Object
A builder for pragmatically creatingAnnotationDescription
.
-
-
Field Summary
Fields Modifier and Type Field Description private TypeDescription
annotationType
The annotation type.private java.util.Map<java.lang.String,AnnotationValue<?,?>>
annotationValues
A mapping of annotation properties to their annotation values.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Builder(TypeDescription annotationType, java.util.Map<java.lang.String,AnnotationValue<?,?>> annotationValues)
Creates a builder for an annotation description.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationDescription
build()
Creates an annotation description for the values that were defined for this builder.AnnotationDescription
build(boolean validated)
Creates an annotation description for the values that were defined for this builder.AnnotationDescription.Builder
define(java.lang.String property, boolean value)
Returns a builder with the additionalboolean
property.AnnotationDescription.Builder
define(java.lang.String property, byte value)
Returns a builder with the additionalbyte
property.AnnotationDescription.Builder
define(java.lang.String property, char value)
Returns a builder with the additionalchar
property.AnnotationDescription.Builder
define(java.lang.String property, double value)
Returns a builder with the additionaldouble
property.AnnotationDescription.Builder
define(java.lang.String property, float value)
Returns a builder with the additionalfloat
property.AnnotationDescription.Builder
define(java.lang.String property, int value)
Returns a builder with the additionalint
property.AnnotationDescription.Builder
define(java.lang.String property, long value)
Returns a builder with the additionallong
property.AnnotationDescription.Builder
define(java.lang.String property, short value)
Returns a builder with the additionalshort
property.AnnotationDescription.Builder
define(java.lang.String property, java.lang.annotation.Annotation annotation)
Returns a builder with the additional annotation property.AnnotationDescription.Builder
define(java.lang.String property, java.lang.Class<?> type)
Returns a builder with the additional class property.AnnotationDescription.Builder
define(java.lang.String property, java.lang.Enum<?> value)
Returns a builder with the additional enumeration property.AnnotationDescription.Builder
define(java.lang.String property, java.lang.String value)
Returns a builder with the additionalString
property.AnnotationDescription.Builder
define(java.lang.String property, AnnotationDescription annotationDescription)
Returns a builder with the additional annotation property.AnnotationDescription.Builder
define(java.lang.String property, AnnotationValue<?,?> value)
Returns a builder with the additional, given property.AnnotationDescription.Builder
define(java.lang.String property, EnumerationDescription value)
Returns a builder with the additional enumeration property.AnnotationDescription.Builder
define(java.lang.String property, TypeDescription typeDescription)
Returns a builder with the additional class property.AnnotationDescription.Builder
define(java.lang.String property, TypeDescription enumerationType, java.lang.String value)
Returns a builder with the additional enumeration property.<T extends java.lang.annotation.Annotation>
AnnotationDescription.BuilderdefineAnnotationArray(java.lang.String property, java.lang.Class<T> annotationType, T... annotation)
Returns a builder with the additional annotation array property.AnnotationDescription.Builder
defineAnnotationArray(java.lang.String property, TypeDescription annotationType, AnnotationDescription... annotationDescription)
Returns a builder with the additional annotation array property.AnnotationDescription.Builder
defineArray(java.lang.String property, boolean... value)
Returns a builder with the additionalboolean
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, byte... value)
Returns a builder with the additionalbyte
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, char... value)
Returns a builder with the additionalchar
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, double... value)
Returns a builder with the additionaldouble
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, float... value)
Returns a builder with the additionalfloat
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, int... value)
Returns a builder with the additionalint
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, long... value)
Returns a builder with the additionallong
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, short... value)
Returns a builder with the additionalshort
array property.AnnotationDescription.Builder
defineArray(java.lang.String property, java.lang.String... value)
Returns a builder with the additionalString
array property.<T extends java.lang.Enum<?>>
AnnotationDescription.BuilderdefineEnumerationArray(java.lang.String property, java.lang.Class<T> enumerationType, T... value)
Returns a builder with the additional enumeration array property.AnnotationDescription.Builder
defineEnumerationArray(java.lang.String property, TypeDescription enumerationType, java.lang.String... value)
Returns a builder with the additional enumeration array property.AnnotationDescription.Builder
defineEnumerationArray(java.lang.String property, TypeDescription enumerationType, EnumerationDescription... value)
Returns a builder with the additional enumeration array property.AnnotationDescription.Builder
defineTypeArray(java.lang.String property, java.lang.Class<?>... type)
Returns a builder with the additional type array property.AnnotationDescription.Builder
defineTypeArray(java.lang.String property, TypeDescription... typeDescription)
Returns a builder with the additional type array property.static AnnotationDescription.Builder
ofType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Creates a builder for creating an annotation of the given type.static AnnotationDescription.Builder
ofType(TypeDescription annotationType)
Creates a builder for creating an annotation of the given type.
-
-
-
Field Detail
-
annotationType
private final TypeDescription annotationType
The annotation type.
-
annotationValues
private final java.util.Map<java.lang.String,AnnotationValue<?,?>> annotationValues
A mapping of annotation properties to their annotation values.
-
-
Constructor Detail
-
Builder
protected Builder(TypeDescription annotationType, java.util.Map<java.lang.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 Detail
-
ofType
public static AnnotationDescription.Builder ofType(java.lang.Class<? extends java.lang.annotation.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(java.lang.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(java.lang.String property, java.lang.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(java.lang.String property, TypeDescription enumerationType, java.lang.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
public AnnotationDescription.Builder define(java.lang.String property, EnumerationDescription value)
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(java.lang.String property, java.lang.annotation.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(java.lang.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(java.lang.String property, java.lang.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(java.lang.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 java.lang.Enum<?>> AnnotationDescription.Builder defineEnumerationArray(java.lang.String property, java.lang.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(java.lang.String property, TypeDescription enumerationType, java.lang.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(java.lang.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 java.lang.annotation.Annotation> AnnotationDescription.Builder defineAnnotationArray(java.lang.String property, java.lang.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(java.lang.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(java.lang.String property, java.lang.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(java.lang.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(java.lang.String property, boolean value)
Returns a builder with the additionalboolean
property.- Parameters:
property
- The name of the property to define.value
- Theboolean
value to define for the property.- Returns:
- A builder with the additional
boolean
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, byte value)
Returns a builder with the additionalbyte
property.- Parameters:
property
- The name of the property to define.value
- Thebyte
value to define for the property.- Returns:
- A builder with the additional
byte
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, char value)
Returns a builder with the additionalchar
property.- Parameters:
property
- The name of the property to define.value
- Thechar
value to define for the property.- Returns:
- A builder with the additional
char
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, short value)
Returns a builder with the additionalshort
property.- Parameters:
property
- The name of the property to define.value
- Theshort
value to define for the property.- Returns:
- A builder with the additional
short
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, int value)
Returns a builder with the additionalint
property.- Parameters:
property
- The name of the property to define.value
- Theint
value to define for the property.- Returns:
- A builder with the additional
int
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, long value)
Returns a builder with the additionallong
property.- Parameters:
property
- The name of the property to define.value
- Thelong
value to define for the property.- Returns:
- A builder with the additional
long
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, float value)
Returns a builder with the additionalfloat
property.- Parameters:
property
- The name of the property to define.value
- Thefloat
value to define for the property.- Returns:
- A builder with the additional
float
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, double value)
Returns a builder with the additionaldouble
property.- Parameters:
property
- The name of the property to define.value
- Thedouble
value to define for the property.- Returns:
- A builder with the additional
double
property.
-
define
public AnnotationDescription.Builder define(java.lang.String property, java.lang.String value)
Returns a builder with the additionalString
property.- Parameters:
property
- The name of the property to define.value
- TheString
value to define for the property.- Returns:
- A builder with the additional
String
property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, boolean... value)
Returns a builder with the additionalboolean
array property.- Parameters:
property
- The name of the property to define.value
- Theboolean
values to define for the property.- Returns:
- A builder with the additional
boolean
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, byte... value)
Returns a builder with the additionalbyte
array property.- Parameters:
property
- The name of the property to define.value
- Thebyte
values to define for the property.- Returns:
- A builder with the additional
byte
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, char... value)
Returns a builder with the additionalchar
array property.- Parameters:
property
- The name of the property to define.value
- Thechar
values to define for the property.- Returns:
- A builder with the additional
char
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, short... value)
Returns a builder with the additionalshort
array property.- Parameters:
property
- The name of the property to define.value
- Theshort
values to define for the property.- Returns:
- A builder with the additional
short
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, int... value)
Returns a builder with the additionalint
array property.- Parameters:
property
- The name of the property to define.value
- Theint
values to define for the property.- Returns:
- A builder with the additional
int
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, long... value)
Returns a builder with the additionallong
array property.- Parameters:
property
- The name of the property to define.value
- Thelong
values to define for the property.- Returns:
- A builder with the additional
long
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, float... value)
Returns a builder with the additionalfloat
array property.- Parameters:
property
- The name of the property to define.value
- Thefloat
values to define for the property.- Returns:
- A builder with the additional
float
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, double... value)
Returns a builder with the additionaldouble
array property.- Parameters:
property
- The name of the property to define.value
- Thedouble
values to define for the property.- Returns:
- A builder with the additional
double
array property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, java.lang.String... value)
Returns a builder with the additionalString
array property.- Parameters:
property
- The name of the property to define.value
- TheString
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.
-
-