public class AnnotationBuilder extends Object
Constructing an AnnotationMirror
requires:
setValue
methods
build()
to get the annotation
IllegalStateException
is thrown.
All setter methods throw IllegalArgumentException
if the specified element is not
found, or if the given value is not a subtype of the expected type.
TODO: Doesn't type-check arrays yet
Constructor and Description |
---|
AnnotationBuilder(ProcessingEnvironment env,
AnnotationMirror annotation) |
AnnotationBuilder(ProcessingEnvironment env,
CharSequence name) |
AnnotationBuilder(ProcessingEnvironment env,
Class<? extends Annotation> anno) |
public AnnotationBuilder(ProcessingEnvironment env, Class<? extends Annotation> anno)
public AnnotationBuilder(ProcessingEnvironment env, CharSequence name)
public AnnotationBuilder(ProcessingEnvironment env, AnnotationMirror annotation)
public static AnnotationMirror fromClass(Elements elements, Class<? extends Annotation> clazz)
AnnotationMirror
given by a particular annotation class.elements
- the element utilities to useclazz
- the annotation classAnnotationMirror
of type given typepublic static AnnotationMirror fromName(Elements elements, CharSequence name)
AnnotationMirror
given by a particular fully-qualified name.
getElementValues on the result returns an empty map.elements
- the element utilities to usename
- the name of the annotation to createAnnotationMirror
of type namepublic static void clear()
public AnnotationMirror build()
public void copyElementValuesFromAnnotation(AnnotationMirror valueHolder, String... ignorableElements)
ignorableElements
.valueHolder
- the annotation that holds the values to be copiedignorableElements
- the elements that can be safely droppedpublic AnnotationBuilder setValue(CharSequence elementName, AnnotationMirror value)
public AnnotationBuilder setValue(CharSequence elementName, List<? extends Object> values)
public AnnotationBuilder setValue(CharSequence elementName, Object[] values)
public AnnotationBuilder setValue(CharSequence elementName, Boolean value)
public AnnotationBuilder setValue(CharSequence elementName, Character value)
public AnnotationBuilder setValue(CharSequence elementName, Double value)
public AnnotationBuilder setValue(CharSequence elementName, Float value)
public AnnotationBuilder setValue(CharSequence elementName, Integer value)
public AnnotationBuilder setValue(CharSequence elementName, Long value)
public AnnotationBuilder setValue(CharSequence elementName, Short value)
public AnnotationBuilder setValue(CharSequence elementName, String value)
public AnnotationBuilder setValue(CharSequence elementName, TypeMirror value)
public AnnotationBuilder setValue(CharSequence elementName, Class<?> value)
public AnnotationBuilder setValue(CharSequence elementName, Enum<?> value)
public AnnotationBuilder setValue(CharSequence elementName, VariableElement value)
public AnnotationBuilder setValue(CharSequence elementName, Enum<?>[] values)
public AnnotationBuilder setValue(CharSequence elementName, VariableElement[] values)
public ExecutableElement findElement(CharSequence key)