public class AnnotationApiHelper extends Object
Constructor and Description |
---|
AnnotationApiHelper(Elements elementUtils,
Types typeUtils) |
Modifier and Type | Method and Description |
---|---|
List<AnnotationMirror> |
filterByType(List<? extends AnnotationMirror> annotationMirrors,
TypeMirror annotationType)
Returns a list containing those annotation mirrors from the input list,
which are of type
annotationType . |
List<? extends AnnotationValue> |
getAnnotationArrayValue(AnnotationMirror annotationMirror,
String name)
Returns the given annotation mirror's array-typed annotation value with
the given name.
|
AnnotationValue |
getAnnotationValue(AnnotationMirror annotationMirror,
String name)
Returns the annotation value of the given annotation mirror with the
given name.
|
DeclaredType |
getDeclaredTypeByName(String className)
Returns the
DeclaredType for the given class name. |
AnnotationMirror |
getMirror(List<? extends AnnotationMirror> annotationMirrors,
Class<? extends Annotation> annotationClazz)
Returns that mirror from the given list of annotation mirrors that
represents the annotation type specified by the given class.
|
AnnotationMirror |
getMirror(List<? extends AnnotationMirror> annotationMirrors,
String annotationTypeName)
Returns that mirror from the given list of annotation mirrors that
represents the annotation type specified by the given class.
|
TypeMirror |
getMirrorForType(Class<?> clazz)
Returns a TypeMirror for the given class.
|
Set<TypeMirror> |
keepLowestTypePerHierarchy(Set<TypeMirror> types)
Returns a set containing the "lowest" type per hierarchy contained in the
input set.
|
public List<AnnotationMirror> filterByType(List<? extends AnnotationMirror> annotationMirrors, TypeMirror annotationType)
annotationType
. The input collection
remains untouched.annotationMirrors
- A list of annotation mirrors.annotationType
- The type to be compared against.annotationType
. May be empty but never
null.public AnnotationMirror getMirror(List<? extends AnnotationMirror> annotationMirrors, Class<? extends Annotation> annotationClazz)
annotationMirrors
- A list of annotation mirrors.annotationClazz
- The class of the annotation of interest.public AnnotationMirror getMirror(List<? extends AnnotationMirror> annotationMirrors, String annotationTypeName)
annotationMirrors
- A list of annotation mirrors.annotationTypeName
- The FQN of the annotation of interest.public TypeMirror getMirrorForType(Class<?> clazz)
clazz
- The class of interest.public DeclaredType getDeclaredTypeByName(String className)
DeclaredType
for the given class name.className
- A fully qualified class name, e.g. "java.lang.String".DeclaredType
representing the type with the given name,
or null, if no such type exists.public AnnotationValue getAnnotationValue(AnnotationMirror annotationMirror, String name)
annotationMirror
- An annotation mirror.name
- The name of the annotation value of interest.public List<? extends AnnotationValue> getAnnotationArrayValue(AnnotationMirror annotationMirror, String name)
annotationMirror
- An annotation mirror.name
- The name of the annotation value of interest.public Set<TypeMirror> keepLowestTypePerHierarchy(Set<TypeMirror> types)
Returns a set containing the "lowest" type per hierarchy contained in the input set. The following examples shall demonstrate the behavior.
String
; Output: String
Object
, String
; Output:
String
Object
, Collection
, List
;
Output: List
Collection
, Set
, List
;
Output: List
, Set
types
- A set of type mirrors.Copyright © 2007-2014 Red Hat Middleware, LLC. All Rights Reserved