|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object checkers.util.AnnotationUtils
@DefaultQualifier(value="checkers.nullness.quals.NonNull") public class AnnotationUtils
A utility class for working with annotations.
Nested Class Summary | |
---|---|
static class |
AnnotationUtils.AnnotationBuilder
Builds an annotation mirror that may have some values. |
Constructor Summary | |
---|---|
AnnotationUtils(ProcessingEnvironment env)
|
Method Summary | ||
---|---|---|
static Name |
annotationName(AnnotationMirror annotation)
|
|
static Comparator<AnnotationMirror> |
annotationOrdering()
provide ordering for AnnotationMirror based on their fully
qualified name. |
|
static boolean |
areSame(AnnotationMirror a1,
AnnotationMirror a2)
Checks if both annotations are the same. |
|
static boolean |
areSame(Collection<AnnotationMirror> c1,
Collection<AnnotationMirror> c2)
Checks that two collections contain the same annotations. |
|
static boolean |
areSameIgnoringValues(AnnotationMirror a1,
AnnotationMirror a2)
|
|
static
|
createAnnotationMap()
Create a map suitable for storing AnnotationMirror as keys. |
|
static Set<AnnotationMirror> |
createAnnotationSet()
Constructs a Set suitable for storing AnnotationMirror s. |
|
Map<TypeElement,Set<DefaultLocation>> |
findDefaultLocations(Element elt)
Finds default annotations starting at the given element, inspecting the element and its enclosing method and class declarations for DefaultQualifier annotations. |
|
Map<TypeElement,Set<DefaultLocation>> |
findDefaultLocations(TreePath path)
Finds default annotations starting at the leaf of the given tree path by inspecting enclosing variable, method, and class declarations for DefaultQualifier annotations. |
|
AnnotationMirror |
fromClass(Class<? extends Annotation> clazz)
Creates an AnnotationMirror given by a particular annotation
class. |
|
AnnotationMirror |
fromName(CharSequence name)
Creates an AnnotationMirror given by a particular
fully-qualified name. |
|
static Map<? extends ExecutableElement,? extends AnnotationValue> |
getElementValuesWithDefaults(AnnotationMirror ad)
Returns the values of an annotation's elements, including defaults. |
|
static
|
parseEnumConstantArrayValue(AnnotationMirror ad,
String field,
Class<R> enumType)
|
|
static Set<String> |
parseStringArrayValue(AnnotationMirror ad,
String field)
|
|
static String |
parseStringValue(AnnotationMirror ad,
String field)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AnnotationUtils(ProcessingEnvironment env)
Method Detail |
---|
public AnnotationMirror fromName(CharSequence name)
AnnotationMirror
given by a particular
fully-qualified name.
name
- the name of the annotation to create
AnnotationMirror
of type
namepublic AnnotationMirror fromClass(Class<? extends Annotation> clazz)
AnnotationMirror
given by a particular annotation
class.
clazz
- the annotation class
AnnotationMirror
of type given typepublic Map<TypeElement,Set<DefaultLocation>> findDefaultLocations(TreePath path)
DefaultQualifier
annotations.
path
- the tree path from which to start searching
TypeElement
s) to the
DefaultLocation
s for those annotationsfindDefaultLocations(Element)
public Map<TypeElement,Set<DefaultLocation>> findDefaultLocations(Element elt)
DefaultQualifier
annotations.
elt
- the element from which to start searching
TypeElement
s) to the
DefaultLocation
s for those annotationsfindDefaultLocations(TreePath)
public static Map<? extends ExecutableElement,? extends AnnotationValue> getElementValuesWithDefaults(AnnotationMirror ad)
ad
- annotation to examine
AnnotationMirror.getElementValues()
public static <R extends Enum<R>> Set<R> parseEnumConstantArrayValue(AnnotationMirror ad, String field, Class<R> enumType)
R
- the enum typead
- the annotation for which a value will be parsedfield
- the name of the field to parseenumType
- the type of the enum
public static String parseStringValue(AnnotationMirror ad, String field)
ad
- the annotation for which a value will be parsedfield
- the name of the field to parse
public static Set<String> parseStringArrayValue(AnnotationMirror ad, String field)
ad
- the annotation for which a value will be parsedfield
- the name of the field to parse
public static final Name annotationName(AnnotationMirror annotation)
public static boolean areSame(AnnotationMirror a1, AnnotationMirror a2)
AnnotationMirror.equals(Object)
. The equals method returns
true iff both annotations are the same and annotate the same annotation
target (e.g. field, variable, etc).
public static boolean areSameIgnoringValues(AnnotationMirror a1, AnnotationMirror a2)
areSame(AnnotationMirror, AnnotationMirror)
public static boolean areSame(Collection<AnnotationMirror> c1, Collection<AnnotationMirror> c2)
public static Comparator<AnnotationMirror> annotationOrdering()
AnnotationMirror
based on their fully
qualified name. The ordering ignores annotation values when ordering.
The ordering is meant to be used as TreeSet
or TreeMap
ordering. A Set
should not contain two annotations that only
differ in values.
public static <V> Map<AnnotationMirror,V> createAnnotationMap()
AnnotationMirror
as keys.
It can store one instance of AnnotationMirror
of a given
declared type, regardless of the annotation element values.
V
- the value of the map
AnnotationMirror
as keypublic static Set<AnnotationMirror> createAnnotationSet()
Set
suitable for storing AnnotationMirror
s.
It stores at most once instance of AnnotationMirror
of a given
type, regardless of the annotation element values.
AnnotationMirror
as element
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |