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 TypeDescriptionannotationTypeThe annotation type.private java.util.Map<java.lang.String,AnnotationValue<?,?>>annotationValuesA mapping of annotation properties to their annotation values.
-
Constructor Summary
Constructors Modifier Constructor Description protectedBuilder(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 AnnotationDescriptionbuild()Creates an annotation description for the values that were defined for this builder.AnnotationDescriptionbuild(boolean validated)Creates an annotation description for the values that were defined for this builder.AnnotationDescription.Builderdefine(java.lang.String property, boolean value)Returns a builder with the additionalbooleanproperty.AnnotationDescription.Builderdefine(java.lang.String property, byte value)Returns a builder with the additionalbyteproperty.AnnotationDescription.Builderdefine(java.lang.String property, char value)Returns a builder with the additionalcharproperty.AnnotationDescription.Builderdefine(java.lang.String property, double value)Returns a builder with the additionaldoubleproperty.AnnotationDescription.Builderdefine(java.lang.String property, float value)Returns a builder with the additionalfloatproperty.AnnotationDescription.Builderdefine(java.lang.String property, int value)Returns a builder with the additionalintproperty.AnnotationDescription.Builderdefine(java.lang.String property, long value)Returns a builder with the additionallongproperty.AnnotationDescription.Builderdefine(java.lang.String property, short value)Returns a builder with the additionalshortproperty.AnnotationDescription.Builderdefine(java.lang.String property, java.lang.annotation.Annotation annotation)Returns a builder with the additional annotation property.AnnotationDescription.Builderdefine(java.lang.String property, java.lang.Class<?> type)Returns a builder with the additional class property.AnnotationDescription.Builderdefine(java.lang.String property, java.lang.Enum<?> value)Returns a builder with the additional enumeration property.AnnotationDescription.Builderdefine(java.lang.String property, java.lang.String value)Returns a builder with the additionalStringproperty.AnnotationDescription.Builderdefine(java.lang.String property, AnnotationDescription annotationDescription)Returns a builder with the additional annotation property.AnnotationDescription.Builderdefine(java.lang.String property, AnnotationValue<?,?> value)Returns a builder with the additional, given property.AnnotationDescription.Builderdefine(java.lang.String property, EnumerationDescription value)Returns a builder with the additional enumeration property.AnnotationDescription.Builderdefine(java.lang.String property, TypeDescription typeDescription)Returns a builder with the additional class property.AnnotationDescription.Builderdefine(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.BuilderdefineAnnotationArray(java.lang.String property, TypeDescription annotationType, AnnotationDescription... annotationDescription)Returns a builder with the additional annotation array property.AnnotationDescription.BuilderdefineArray(java.lang.String property, boolean... value)Returns a builder with the additionalbooleanarray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, byte... value)Returns a builder with the additionalbytearray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, char... value)Returns a builder with the additionalchararray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, double... value)Returns a builder with the additionaldoublearray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, float... value)Returns a builder with the additionalfloatarray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, int... value)Returns a builder with the additionalintarray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, long... value)Returns a builder with the additionallongarray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, short... value)Returns a builder with the additionalshortarray property.AnnotationDescription.BuilderdefineArray(java.lang.String property, java.lang.String... value)Returns a builder with the additionalStringarray 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.BuilderdefineEnumerationArray(java.lang.String property, TypeDescription enumerationType, java.lang.String... value)Returns a builder with the additional enumeration array property.AnnotationDescription.BuilderdefineEnumerationArray(java.lang.String property, TypeDescription enumerationType, EnumerationDescription... value)Returns a builder with the additional enumeration array property.AnnotationDescription.BuilderdefineTypeArray(java.lang.String property, java.lang.Class<?>... type)Returns a builder with the additional type array property.AnnotationDescription.BuilderdefineTypeArray(java.lang.String property, TypeDescription... typeDescription)Returns a builder with the additional type array property.static AnnotationDescription.BuilderofType(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)Creates a builder for creating an annotation of the given type.static AnnotationDescription.BuilderofType(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 additionalbooleanproperty.- Parameters:
property- The name of the property to define.value- Thebooleanvalue to define for the property.- Returns:
- A builder with the additional
booleanproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, byte value)
Returns a builder with the additionalbyteproperty.- Parameters:
property- The name of the property to define.value- Thebytevalue to define for the property.- Returns:
- A builder with the additional
byteproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, char value)
Returns a builder with the additionalcharproperty.- Parameters:
property- The name of the property to define.value- Thecharvalue to define for the property.- Returns:
- A builder with the additional
charproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, short value)
Returns a builder with the additionalshortproperty.- Parameters:
property- The name of the property to define.value- Theshortvalue to define for the property.- Returns:
- A builder with the additional
shortproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, int value)
Returns a builder with the additionalintproperty.- Parameters:
property- The name of the property to define.value- Theintvalue to define for the property.- Returns:
- A builder with the additional
intproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, long value)
Returns a builder with the additionallongproperty.- Parameters:
property- The name of the property to define.value- Thelongvalue to define for the property.- Returns:
- A builder with the additional
longproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, float value)
Returns a builder with the additionalfloatproperty.- Parameters:
property- The name of the property to define.value- Thefloatvalue to define for the property.- Returns:
- A builder with the additional
floatproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, double value)
Returns a builder with the additionaldoubleproperty.- Parameters:
property- The name of the property to define.value- Thedoublevalue to define for the property.- Returns:
- A builder with the additional
doubleproperty.
-
define
public AnnotationDescription.Builder define(java.lang.String property, java.lang.String value)
Returns a builder with the additionalStringproperty.- Parameters:
property- The name of the property to define.value- TheStringvalue to define for the property.- Returns:
- A builder with the additional
Stringproperty.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, boolean... value)
Returns a builder with the additionalbooleanarray property.- Parameters:
property- The name of the property to define.value- Thebooleanvalues to define for the property.- Returns:
- A builder with the additional
booleanarray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, byte... value)
Returns a builder with the additionalbytearray property.- Parameters:
property- The name of the property to define.value- Thebytevalues to define for the property.- Returns:
- A builder with the additional
bytearray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, char... value)
Returns a builder with the additionalchararray property.- Parameters:
property- The name of the property to define.value- Thecharvalues to define for the property.- Returns:
- A builder with the additional
chararray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, short... value)
Returns a builder with the additionalshortarray property.- Parameters:
property- The name of the property to define.value- Theshortvalues to define for the property.- Returns:
- A builder with the additional
shortarray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, int... value)
Returns a builder with the additionalintarray property.- Parameters:
property- The name of the property to define.value- Theintvalues to define for the property.- Returns:
- A builder with the additional
intarray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, long... value)
Returns a builder with the additionallongarray property.- Parameters:
property- The name of the property to define.value- Thelongvalues to define for the property.- Returns:
- A builder with the additional
longarray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, float... value)
Returns a builder with the additionalfloatarray property.- Parameters:
property- The name of the property to define.value- Thefloatvalues to define for the property.- Returns:
- A builder with the additional
floatarray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, double... value)
Returns a builder with the additionaldoublearray property.- Parameters:
property- The name of the property to define.value- Thedoublevalues to define for the property.- Returns:
- A builder with the additional
doublearray property.
-
defineArray
public AnnotationDescription.Builder defineArray(java.lang.String property, java.lang.String... value)
Returns a builder with the additionalStringarray property.- Parameters:
property- The name of the property to define.value- TheStringarray value to define for the property.- Returns:
- A builder with the additional
Stringarray 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-trueif the annotation description should be validated for having included all values.- Returns:
- An appropriate annotation description.
-
-