|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcheckers.util.AnnotationUtils
@DefaultQualifier(value="checkers.nullness.quals.NonNull") public class AnnotationUtils extends Object
A utility class for working with annotations.
Modifier and Type | Class and Description |
---|---|
static class |
AnnotationUtils.AnnotationBuilder
Builds an annotation mirror that may have some values. |
Modifier and Type | Method and Description | |
---|---|---|
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. |
|
static
|
elementValue(AnnotationMirror anno,
CharSequence name,
Class<T> expectedType)
|
|
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. |
|
AnnotationMirror |
fromName(String 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 AnnotationUtils |
getInstance(ProcessingEnvironment env)
|
|
static
|
parseEnumConstantArrayValue(AnnotationMirror ad,
String field,
Class<R> enumType)
|
|
static List<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 |
Method Detail |
---|
public static AnnotationUtils getInstance(ProcessingEnvironment env)
public AnnotationMirror fromName(CharSequence name)
AnnotationMirror
given by a particular
fully-qualified name.
name
- the name of the annotation to createAnnotationMirror
of type
namepublic AnnotationMirror fromName(String name)
AnnotationMirror
given by a particular
fully-qualified name.
name
- the name of the annotation to createAnnotationMirror
of type
namepublic AnnotationMirror fromClass(Class<? extends Annotation> clazz)
AnnotationMirror
given by a particular annotation
class.
clazz
- the annotation classAnnotationMirror
of type given typepublic Map<TypeElement,Set<DefaultLocation>> findDefaultLocations(TreePath path)
DefaultQualifier
annotations.
path
- the tree path from which to start searchingTypeElement
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 searchingTypeElement
s) to the
DefaultLocation
s for those annotationsfindDefaultLocations(TreePath)
public static Map<? extends ExecutableElement,? extends AnnotationValue> getElementValuesWithDefaults(AnnotationMirror ad)
ad
- annotation to examineAnnotationMirror.getElementValues()
@Nullable 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@Nullable 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@Nullable public static List<String> parseStringArrayValue(AnnotationMirror ad, String field)
ad
- the annotation for which a value will be parsedfield
- the name of the field to parse@Nullable public static final Name annotationName(@Nullable AnnotationMirror annotation)
public static boolean areSame(@Nullable AnnotationMirror a1, @Nullable 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 mapAnnotationMirror
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 elementpublic static <T> T elementValue(AnnotationMirror anno, CharSequence name, Class<T> expectedType)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |