Package org.jboss.jandex
Class AnnotationInstanceBuilder
java.lang.Object
org.jboss.jandex.AnnotationInstanceBuilder
Builder for
AnnotationInstance
. Instances of the builder are not reusable.
Expected usage is: call add()
as many times as required to add annotation members,
and then call build()
to create an AnnotationInstance
without target, or
buildWithTarget()
to create an AnnotationInstance
with target.
Attempt to add()
a member with the same name multiple times leads to an exception.
This builder does not check whether the annotation type declares a member with given name or whether that member declares a default value.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DotName
private final boolean
private static final String
private final List
<AnnotationValue> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a boolean-valued annotation member with givenname
.Adds a boolean array-valued annotation member with givenname
.Adds a byte-valued annotation member with givenname
.Adds a byte array-valued annotation member with givenname
.Adds a char-valued annotation member with givenname
.Adds a char array-valued annotation member with givenname
.Adds a double-valued annotation member with givenname
.Adds a double array-valued annotation member with givenname
.Adds a float-valued annotation member with givenname
.Adds a float array-valued annotation member with givenname
.Adds an int-valued annotation member with givenname
.Adds an int array-valued annotation member with givenname
.Adds a long-valued annotation member with givenname
.Adds a long array-valued annotation member with givenname
.Adds a short-valued annotation member with givenname
.Adds a short array-valued annotation member with givenname
.Adds a class-valued annotation member with givenname
.Adds a class array-valued annotation member with givenname
.Adds an enum-valued annotation member with givenname
.Adds an enum array-valued annotation member with givenname
.Adds an enum-valued annotation member with givenname
.Adds an enum array-valued annotation member with givenname
.Adds a String-valued annotation member with givenname
.Adds a String array-valued annotation member with givenname
.add
(String name, AnnotationInstance value) Adds an annotation-valued annotation member with givenname
.add
(String name, AnnotationInstance[] values) Adds an annotation array-valued annotation member with givenname
.Adds a class-valued annotation member with givenname
.Adds a class array-valued annotation member with givenname
.Adds an enum-valued annotation member with givenname
.Adds an enum array-valued annotation member with givenname
.Adds a class-valued annotation member with givenname
.Adds a class array-valued annotation member with givenname
.add
(AnnotationValue value) Adds a pre-defined annotation member whose name and value are defined by givenvalue
.addAll
(List<AnnotationValue> values) Adds all pre-defined annotation members whose names and values are defined by givenvalues
.build()
Returns anAnnotationInstance
that includes all annotation members defined by previous method calls on this builder.buildWithTarget
(AnnotationTarget target) Returns anAnnotationInstance
that includes all annotation members defined by previous method calls on this builder.private void
validateType
(Type type) value
(boolean value) Adds a boolean-valued annotation member calledvalue
.value
(boolean[] values) Adds a boolean array-valued annotation member calledvalue
.value
(byte value) Adds a byte-valued annotation member calledvalue
.value
(byte[] values) Adds a byte array-valued annotation member calledvalue
.value
(char value) Adds a char-valued annotation member calledvalue
.value
(char[] values) Adds a char array-valued annotation member calledvalue
.value
(double value) Adds a double-valued annotation member calledvalue
.value
(double[] values) Adds a double array-valued annotation member calledvalue
.value
(float value) Adds a float-valued annotation member calledvalue
.value
(float[] values) Adds a float array-valued annotation member calledvalue
.value
(int value) Adds an int-valued annotation member calledvalue
.value
(int[] values) Adds an int array-valued annotation member calledvalue
.value
(long value) Adds a long-valued annotation member calledvalue
.value
(long[] values) Adds a long array-valued annotation member calledvalue
.value
(short value) Adds a short-valued annotation member calledvalue
.value
(short[] values) Adds a short array-valued annotation member calledvalue
.Adds a class-valued annotation member calledvalue
.Adds a class array-valued annotation member calledvalue
.Adds an enum-valued annotation member calledvalue
.Adds an enum array-valued annotation member calledvalue
.Adds an enum-valued annotation member calledvalue
.Adds an enum array-valued annotation member calledvalue
.Adds a String-valued annotation member calledvalue
.Adds a String array-valued annotation member calledvalue
.value
(AnnotationInstance value) Adds an annotation-valued annotation member calledvalue
.value
(AnnotationInstance[] values) Adds an annotation array-valued annotation member calledvalue
.Adds a class-valued annotation member calledvalue
.Adds a class array-valued annotation member calledvalue
.Adds an enum-valued annotation member calledvalue
.Adds an enum array-valued annotation member calledvalue
.Adds a class-valued annotation member calledvalue
.Adds a class array-valued annotation member calledvalue
.with
(Consumer<AnnotationInstanceBuilder> action) Calls givenaction
with this builder as an argument, and returns this builder after the action finishes.
-
Field Details
-
VALUE
- See Also:
-
annotationType
-
runtimeVisible
private final boolean runtimeVisible -
values
-
alreadyAdded
-
-
Constructor Details
-
AnnotationInstanceBuilder
AnnotationInstanceBuilder(DotName annotationType, boolean runtimeVisible)
-
-
Method Details
-
add
Adds a pre-defined annotation member whose name and value are defined by givenvalue
.- Parameters:
value
- the pre-defined annotation member, must not benull
- Returns:
- this builder
-
addAll
Adds all pre-defined annotation members whose names and values are defined by givenvalues
.- Parameters:
values
- the pre-defined annotation members, must not benull
or containnull
- Returns:
- this builder
-
add
Adds a boolean-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the boolean value- Returns:
- this builder
-
add
Adds a boolean array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the boolean array, must not benull
- Returns:
- this builder
-
add
Adds a byte-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the byte value- Returns:
- this builder
-
add
Adds a byte array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the byte array, must not benull
- Returns:
- this builder
-
add
Adds a short-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the short value- Returns:
- this builder
-
add
Adds a short array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the short array, must not benull
- Returns:
- this builder
-
add
Adds an int-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the int value- Returns:
- this builder
-
add
Adds an int array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the int array, must not benull
- Returns:
- this builder
-
add
Adds a long-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the long value- Returns:
- this builder
-
add
Adds a long array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the long array, must not benull
- Returns:
- this builder
-
add
Adds a float-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the float value- Returns:
- this builder
-
add
Adds a float array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the float array, must not benull
- Returns:
- this builder
-
add
Adds a double-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the double value- Returns:
- this builder
-
add
Adds a double array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the double array, must not benull
- Returns:
- this builder
-
add
Adds a char-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the char value- Returns:
- this builder
-
add
Adds a char array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the char array, must not benull
- Returns:
- this builder
-
add
Adds a String-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the String value, must not benull
- Returns:
- this builder
-
add
Adds a String array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the String array, must not benull
or containnull
- Returns:
- this builder
-
add
Adds an enum-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the enum value, must not benull
- Returns:
- this builder
-
add
Adds an enum array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the enum array, must not benull
or containnull
- Returns:
- this builder
-
add
public AnnotationInstanceBuilder add(String name, Class<? extends Enum<?>> enumType, String enumValue) Adds an enum-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
enumType
- the enum type, must not benull
enumValue
- name of the enum constant, must not benull
- Returns:
- this builder
-
add
public AnnotationInstanceBuilder add(String name, Class<? extends Enum<?>> enumType, String[] enumValues) Adds an enum array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
enumType
- the enum type, must not benull
enumValues
- names of the enum constants, must not benull
or containnull
- Returns:
- this builder
-
add
Adds an enum-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
enumType
- the enum type, must not benull
enumValue
- name of the enum constant, must not benull
- Returns:
- this builder
-
add
Adds an enum array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
enumType
- the enum type, must not benull
enumValues
- names of the enum constants, must not benull
or containnull
- Returns:
- this builder
-
add
Adds a class-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the class value, must not benull
- Returns:
- this builder
-
add
Adds a class array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the class array, must not benull
or containnull
- Returns:
- this builder
-
add
Adds a class-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the class value, must not benull
- Returns:
- this builder
-
add
Adds a class array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the class array, must not benull
or containnull
- Returns:
- this builder
-
validateType
-
add
Adds a class-valued annotation member with givenname
. Thevalue
parameter may only be:VoidType
;PrimitiveType
;ClassType
;ArrayType
whose element type is eitherPrimitiveType
orClassType
.
- Parameters:
name
- the member name, must not benull
value
- the class value, must not benull
- Returns:
- this builder
- Throws:
IllegalArgumentException
- if given type is invalid, as described above
-
add
Adds a class array-valued annotation member with givenname
. Thevalues
parameter may only include:VoidType
;PrimitiveType
;ClassType
;ArrayType
whose element type is eitherPrimitiveType
orClassType
.
- Parameters:
name
- the member name, must not benull
values
- the class array, must not benull
or containnull
- Returns:
- this builder
- Throws:
IllegalArgumentException
- if any given type is invalid, as described above
-
add
Adds an annotation-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the annotation value, must not benull
- Returns:
- this builder
-
add
Adds an annotation array-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
values
- the annotation array, must not benull
or containnull
- Returns:
- this builder
-
value
Adds a boolean-valued annotation member calledvalue
.- Parameters:
value
- the boolean value- Returns:
- this builder
-
value
Adds a boolean array-valued annotation member calledvalue
.- Parameters:
values
- the boolean array, must not benull
- Returns:
- this builder
-
value
Adds a byte-valued annotation member calledvalue
.- Parameters:
value
- the byte value- Returns:
- this builder
-
value
Adds a byte array-valued annotation member calledvalue
.- Parameters:
values
- the byte array, must not benull
- Returns:
- this builder
-
value
Adds a short-valued annotation member calledvalue
.- Parameters:
value
- the short value- Returns:
- this builder
-
value
Adds a short array-valued annotation member calledvalue
.- Parameters:
values
- the short array, must not benull
- Returns:
- this builder
-
value
Adds an int-valued annotation member calledvalue
.- Parameters:
value
- the int value- Returns:
- this builder
-
value
Adds an int array-valued annotation member calledvalue
.- Parameters:
values
- the int array, must not benull
- Returns:
- this builder
-
value
Adds a long-valued annotation member calledvalue
.- Parameters:
value
- the long value- Returns:
- this builder
-
value
Adds a long array-valued annotation member calledvalue
.- Parameters:
values
- the long array, must not benull
- Returns:
- this builder
-
value
Adds a float-valued annotation member calledvalue
.- Parameters:
value
- the float value- Returns:
- this builder
-
value
Adds a float array-valued annotation member calledvalue
.- Parameters:
values
- the float array, must not benull
- Returns:
- this builder
-
value
Adds a double-valued annotation member calledvalue
.- Parameters:
value
- the double value- Returns:
- this builder
-
value
Adds a double array-valued annotation member calledvalue
.- Parameters:
values
- the double array, must not benull
- Returns:
- this builder
-
value
Adds a char-valued annotation member calledvalue
.- Parameters:
value
- the char value- Returns:
- this builder
-
value
Adds a char array-valued annotation member calledvalue
.- Parameters:
values
- the char array, must not benull
- Returns:
- this builder
-
value
Adds a String-valued annotation member calledvalue
.- Parameters:
value
- the String value, must not benull
- Returns:
- this builder
-
value
Adds a String array-valued annotation member calledvalue
.- Parameters:
values
- the String array, must not benull
or containnull
- Returns:
- this builder
-
value
Adds an enum-valued annotation member calledvalue
.- Parameters:
value
- the enum value, must not benull
- Returns:
- this builder
-
value
Adds an enum array-valued annotation member calledvalue
.- Parameters:
values
- the enum array, must not benull
or containnull
- Returns:
- this builder
-
value
Adds an enum-valued annotation member calledvalue
.- Parameters:
enumType
- the enum type, must not benull
enumValue
- name of the enum constant, must not benull
- Returns:
- this builder
-
value
Adds an enum array-valued annotation member calledvalue
.- Parameters:
enumType
- the enum type, must not benull
enumValues
- names of the enum constants, must not benull
or containnull
- Returns:
- this builder
-
value
Adds an enum-valued annotation member calledvalue
.- Parameters:
enumType
- the enum type, must not benull
enumValue
- name of the enum constant, must not benull
- Returns:
- this builder
-
value
Adds an enum array-valued annotation member calledvalue
.- Parameters:
enumType
- the enum type, must not benull
enumValues
- names of the enum constants, must not benull
or containnull
- Returns:
- this builder
-
value
Adds a class-valued annotation member calledvalue
.- Parameters:
value
- the class value, must not benull
- Returns:
- this builder
-
value
Adds a class array-valued annotation member calledvalue
.- Parameters:
values
- the class array, must not benull
or containnull
- Returns:
- this builder
-
value
Adds a class-valued annotation member calledvalue
.- Parameters:
value
- the class value, must not benull
- Returns:
- this builder
-
value
Adds a class array-valued annotation member calledvalue
.- Parameters:
values
- the class array, must not benull
or containnull
- Returns:
- this builder
-
value
Adds a class-valued annotation member calledvalue
. Thevalue
parameter may only be:VoidType
;PrimitiveType
;ClassType
;ArrayType
whose element type is eitherPrimitiveType
orClassType
.
- Parameters:
value
- the class value, must not benull
- Returns:
- this builder
- Throws:
IllegalArgumentException
- if given type is invalid, as described above
-
value
Adds a class array-valued annotation member calledvalue
. Thevalues
parameter may only contain:VoidType
;PrimitiveType
;ClassType
;ArrayType
whose element type is eitherPrimitiveType
orClassType
.
- Parameters:
values
- the class array, must not benull
or containnull
- Returns:
- this builder
- Throws:
IllegalArgumentException
- if any given type is invalid, as described above
-
value
Adds an annotation-valued annotation member calledvalue
.- Parameters:
value
- the annotation value, must not benull
- Returns:
- this builder
-
value
Adds an annotation array-valued annotation member calledvalue
.- Parameters:
values
- the annotation array, must not benull
or containnull
- Returns:
- this builder
-
with
Calls givenaction
with this builder as an argument, and returns this builder after the action finishes. This is useful to express a non-trivial control flow without breaking fluent usage.- Parameters:
action
- an action to be performed on this builder, must not benull
- Returns:
- this builder
-
build
Returns anAnnotationInstance
that includes all annotation members defined by previous method calls on this builder. The returnedAnnotationInstance
has no target. Afterbuild()
is called, this builder instance should be discarded.- Returns:
- the built
AnnotationInstance
, nevernull
-
buildWithTarget
Returns anAnnotationInstance
that includes all annotation members defined by previous method calls on this builder. The returnedAnnotationInstance
has giventarget
. AfterbuildWithTarget()
is called, this builder instance should be discarded.- Parameters:
target
- the target of the built annotation instance; ifnull
, the built annotation instance has no target- Returns:
- the built
AnnotationInstance
, nevernull
-