Interface AnnotationBuilder
public interface AnnotationBuilder
Builder for annotations of given type.
Expected usage is:
- create the builder using
of(Class)
orof(ClassInfo)
; - use the
value()
andmember()
methods to define annotation members; - call
build()
to create anAnnotationInfo
.
Note that values of all members of given annotation type must be defined before
calling build()
, except of annotation members that declare a default value.
If a value is not defined for an annotation member that does not have a default value,
build()
will throw an exception.
Defining values of members that do not exist on given annotation type is possible,
and such members will be retained in the resulting AnnotationInfo
. However,
if that AnnotationInfo
is later transformed to an instance of the annotation
type, the non-existing members will disappear.
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns anAnnotationInfo
that includes all annotation members defined by previous method calls on this builder.Adds 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
.member
(String name, AnnotationInfo value) Adds an annotation-valued annotation member with givenname
.member
(String name, AnnotationInfo[] values) Adds an annotation array-valued annotation member with givenname
.member
(String name, AnnotationMember value) Adds an annotation member with givenname
, whose value is givenvalue
.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
.member
(String name, Annotation value) Adds an annotation-valued annotation member with givenname
.member
(String name, Annotation[] 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 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
.static AnnotationBuilder
Returns a newAnnotationBuilder
that builds an annotation of given type.static AnnotationBuilder
of
(Class<? extends Annotation> annotationType) Returns a newAnnotationBuilder
that builds an annotation of given type.default AnnotationBuilder
value
(boolean value) Adds a boolean-valued annotation member calledvalue
.default AnnotationBuilder
value
(boolean[] values) Adds a boolean array-valued annotation member calledvalue
.default AnnotationBuilder
value
(byte value) Adds a byte-valued annotation member calledvalue
.default AnnotationBuilder
value
(byte[] values) Adds a byte array-valued annotation member calledvalue
.default AnnotationBuilder
value
(char value) Adds a char-valued annotation member calledvalue
.default AnnotationBuilder
value
(char[] values) Adds a char array-valued annotation member calledvalue
.default AnnotationBuilder
value
(double value) Adds a double-valued annotation member calledvalue
.default AnnotationBuilder
value
(double[] values) Adds a double array-valued annotation member calledvalue
.default AnnotationBuilder
value
(float value) Adds a float-valued annotation member calledvalue
.default AnnotationBuilder
value
(float[] values) Adds a float array-valued annotation member calledvalue
.default AnnotationBuilder
value
(int value) Adds an int-valued annotation member calledvalue
.default AnnotationBuilder
value
(int[] values) Adds an int array-valued annotation member calledvalue
.default AnnotationBuilder
value
(long value) Adds a long-valued annotation member calledvalue
.default AnnotationBuilder
value
(long[] values) Adds a long array-valued annotation member calledvalue
.default AnnotationBuilder
value
(short value) Adds a short-valued annotation member calledvalue
.default AnnotationBuilder
value
(short[] values) Adds a short array-valued annotation member calledvalue
.default AnnotationBuilder
value
(AnnotationInfo value) Adds an annotation-valued annotation member calledvalue
.default AnnotationBuilder
value
(AnnotationInfo[] values) Adds an annotation array-valued annotation member calledvalue
.default AnnotationBuilder
value
(AnnotationMember value) Adds an annotation member calledvalue
, whose value is givenvalue
.default AnnotationBuilder
Adds a class-valued annotation member calledvalue
.default AnnotationBuilder
Adds a class array-valued annotation member calledvalue
.default AnnotationBuilder
Adds an enum-valued annotation member calledvalue
.default AnnotationBuilder
Adds an enum array-valued annotation member calledvalue
.default AnnotationBuilder
Adds a class-valued annotation member calledvalue
.default AnnotationBuilder
Adds a class array-valued annotation member calledvalue
.default AnnotationBuilder
value
(Annotation value) Adds an annotation-valued annotation member calledvalue
.default AnnotationBuilder
value
(Annotation[] values) Adds an annotation array-valued annotation member calledvalue
.default AnnotationBuilder
Adds a class-valued annotation member calledvalue
.default AnnotationBuilder
Adds a class array-valued annotation member calledvalue
.default AnnotationBuilder
Adds an enum-valued annotation member calledvalue
.default AnnotationBuilder
Adds an enum array-valued annotation member calledvalue
.default AnnotationBuilder
Adds an enum-valued annotation member calledvalue
.default AnnotationBuilder
Adds an enum array-valued annotation member calledvalue
.default AnnotationBuilder
Adds a String-valued annotation member calledvalue
.default AnnotationBuilder
Adds a String array-valued annotation member calledvalue
.
-
Method Details
-
of
Returns a newAnnotationBuilder
that builds an annotation of given type.- Parameters:
annotationType
- the annotation type, must not benull
- Returns:
- a new
AnnotationBuilder
, nevernull
-
of
Returns a newAnnotationBuilder
that builds an annotation of given type.- Parameters:
annotationType
- the annotation type, must not benull
- Returns:
- a new
AnnotationBuilder
-
value
Adds an annotation member calledvalue
, whose value is givenvalue
.- Parameters:
value
- value of the annotation member- Returns:
- this
AnnotationBuilder
-
value
Adds a boolean-valued annotation member calledvalue
.- Parameters:
value
- the boolean value- Returns:
- this
AnnotationBuilder
-
value
Adds a boolean array-valued annotation member calledvalue
.- Parameters:
values
- the boolean array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a byte-valued annotation member calledvalue
.- Parameters:
value
- the byte value- Returns:
- this
AnnotationBuilder
-
value
Adds a byte array-valued annotation member calledvalue
.- Parameters:
values
- the byte array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a short-valued annotation member calledvalue
.- Parameters:
value
- the short value- Returns:
- this
AnnotationBuilder
-
value
Adds a short array-valued annotation member calledvalue
.- Parameters:
values
- the short array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds an int-valued annotation member calledvalue
.- Parameters:
value
- the int value- Returns:
- this
AnnotationBuilder
-
value
Adds an int array-valued annotation member calledvalue
.- Parameters:
values
- the int array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a long-valued annotation member calledvalue
.- Parameters:
value
- the long value- Returns:
- this
AnnotationBuilder
-
value
Adds a long array-valued annotation member calledvalue
.- Parameters:
values
- the long array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a float-valued annotation member calledvalue
.- Parameters:
value
- the float value- Returns:
- this
AnnotationBuilder
-
value
Adds a float array-valued annotation member calledvalue
.- Parameters:
values
- the float array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a double-valued annotation member calledvalue
.- Parameters:
value
- the double value- Returns:
- this
AnnotationBuilder
-
value
Adds a double array-valued annotation member calledvalue
.- Parameters:
values
- the double array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a char-valued annotation member calledvalue
.- Parameters:
value
- the char value- Returns:
- this
AnnotationBuilder
-
value
Adds a char array-valued annotation member calledvalue
.- Parameters:
values
- the char array, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a String-valued annotation member calledvalue
.- Parameters:
value
- the String value, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a String array-valued annotation member calledvalue
.- Parameters:
values
- the String array, must not benull
or containnull
- Returns:
- this
AnnotationBuilder
-
value
Adds an enum-valued annotation member calledvalue
.- Parameters:
value
- the enum value, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds an enum array-valued annotation member calledvalue
.- Parameters:
values
- the enum array, must not benull
or containnull
- Returns:
- this
AnnotationBuilder
-
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
AnnotationBuilder
-
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
AnnotationBuilder
-
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
AnnotationBuilder
-
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
AnnotationBuilder
-
value
Adds a class-valued annotation member calledvalue
.- Parameters:
value
- the class value, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a class array-valued annotation member calledvalue
.- Parameters:
values
- the class array, must not benull
or containnull
- Returns:
- this
AnnotationBuilder
-
value
Adds a class-valued annotation member calledvalue
.- Parameters:
value
- the class value, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds a class array-valued annotation member calledvalue
.- Parameters:
values
- the class array, must not benull
or containnull
- Returns:
- this
AnnotationBuilder
-
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
AnnotationBuilder
- 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
AnnotationBuilder
- 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
AnnotationBuilder
-
value
Adds an annotation array-valued annotation member calledvalue
.- Parameters:
values
- the annotation array, must not benull
or containnull
- Returns:
- this
AnnotationBuilder
-
value
Adds an annotation-valued annotation member calledvalue
.- Parameters:
value
- the annotation value, must not benull
- Returns:
- this
AnnotationBuilder
-
value
Adds an annotation array-valued annotation member calledvalue
.- Parameters:
values
- the annotation array, must not benull
or containnull
- Returns:
- this
AnnotationBuilder
-
member
Adds an annotation member with givenname
, whose value is givenvalue
.- Parameters:
name
- name of the annotation member, must not benull
value
- value of the annotation member, must not benull
- Returns:
- this
AnnotationBuilder
-
member
Adds a boolean-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the boolean value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds a byte-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the byte value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds a short-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the short value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds an int-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the int value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds a long-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the long value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds a float-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the float value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds a double-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the double value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
Adds a char-valued annotation member with givenname
.- Parameters:
name
- the member name, must not benull
value
- the char value- Returns:
- this
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
- Throws:
IllegalArgumentException
- if given type is invalid, as described above
-
member
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
AnnotationBuilder
- Throws:
IllegalArgumentException
- if any given type is invalid, as described above
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
member
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
AnnotationBuilder
-
build
AnnotationInfo build()Returns anAnnotationInfo
that includes all annotation members defined by previous method calls on this builder. Afterbuild()
is called, this builder instance should be discarded.- Returns:
- the built
AnnotationInfo
, nevernull
- Throws:
IllegalStateException
- if a value of some annotation member was not set, and that member does not declare a default value
-