public class AnnotationApiHelper
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
AnnotationApiHelper.UnwrapMode |
Constructor and Description |
---|
AnnotationApiHelper(javax.lang.model.util.Elements elementUtils,
javax.lang.model.util.Types typeUtils) |
Modifier and Type | Method and Description |
---|---|
AnnotationApiHelper.UnwrapMode |
determineUnwrapMode(javax.lang.model.element.AnnotationMirror annotationMirror)
Checks the annotation's payload for unwrapping option (
javax.validation.valueextraction.Unwrapping.Unwrap ,
javax.validation.valueextraction.Unwrapping.Skip ) of constraint. |
java.util.List<javax.lang.model.element.AnnotationMirror> |
filterByType(java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationMirrors,
javax.lang.model.type.TypeMirror annotationType)
Returns a list containing those annotation mirrors from the input list,
which are of type
annotationType . |
java.util.List<? extends javax.lang.model.element.AnnotationValue> |
getAnnotationArrayValue(javax.lang.model.element.AnnotationMirror annotationMirror,
java.lang.String name)
Returns the given annotation mirror's array-typed annotation value with
the given name.
|
javax.lang.model.element.AnnotationValue |
getAnnotationValue(javax.lang.model.element.AnnotationMirror annotationMirror,
java.lang.String name)
Returns the annotation value of the given annotation mirror with the
given name.
|
javax.lang.model.element.AnnotationValue |
getAnnotationValueOrDefault(javax.lang.model.element.AnnotationMirror annotationMirror,
java.lang.String name)
Returns the annotation value of the given annotation mirror with the
given name or its default value if it was not specified.
|
javax.lang.model.type.DeclaredType |
getDeclaredTypeByName(java.lang.String className)
Returns the
DeclaredType for the given class name. |
javax.lang.model.element.AnnotationMirror |
getMirror(java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationMirrors,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationClazz)
Returns that mirror from the given list of annotation mirrors that
represents the annotation type specified by the given class.
|
javax.lang.model.element.AnnotationMirror |
getMirror(java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationMirrors,
java.lang.String annotationTypeName)
Returns that mirror from the given list of annotation mirrors that
represents the annotation type specified by the given class.
|
javax.lang.model.type.TypeMirror |
getMirrorForType(java.lang.Class<?> clazz)
Returns a TypeMirror for the given class.
|
boolean |
isClass(javax.lang.model.type.TypeMirror typeMirror)
Test if the given
TypeMirror represents a class or not. |
boolean |
isInterface(javax.lang.model.type.TypeMirror typeMirror)
Test if the given
TypeMirror represents an interface or not. |
java.util.Set<javax.lang.model.type.TypeMirror> |
keepLowestTypePerHierarchy(java.util.Set<javax.lang.model.type.TypeMirror> types)
Returns a set containing the "lowest" type per hierarchy contained in the
input set.
|
public AnnotationApiHelper(javax.lang.model.util.Elements elementUtils, javax.lang.model.util.Types typeUtils)
public java.util.List<javax.lang.model.element.AnnotationMirror> filterByType(java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationMirrors, javax.lang.model.type.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 javax.lang.model.element.AnnotationMirror getMirror(java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationMirrors, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClazz)
annotationMirrors
- A list of annotation mirrors.annotationClazz
- The class of the annotation of interest.public javax.lang.model.element.AnnotationMirror getMirror(java.util.List<? extends javax.lang.model.element.AnnotationMirror> annotationMirrors, java.lang.String annotationTypeName)
annotationMirrors
- A list of annotation mirrors.annotationTypeName
- The FQN of the annotation of interest.public javax.lang.model.type.TypeMirror getMirrorForType(java.lang.Class<?> clazz)
clazz
- The class of interest.public javax.lang.model.type.DeclaredType getDeclaredTypeByName(java.lang.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 javax.lang.model.element.AnnotationValue getAnnotationValue(javax.lang.model.element.AnnotationMirror annotationMirror, java.lang.String name)
annotationMirror
- An annotation mirror.name
- The name of the annotation value of interest.public javax.lang.model.element.AnnotationValue getAnnotationValueOrDefault(javax.lang.model.element.AnnotationMirror annotationMirror, java.lang.String name)
annotationMirror
- An annotation mirror.name
- The name of the annotation value of interest.public java.util.List<? extends javax.lang.model.element.AnnotationValue> getAnnotationArrayValue(javax.lang.model.element.AnnotationMirror annotationMirror, java.lang.String name)
annotationMirror
- An annotation mirror.name
- The name of the annotation value of interest.public java.util.Set<javax.lang.model.type.TypeMirror> keepLowestTypePerHierarchy(java.util.Set<javax.lang.model.type.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.public boolean isInterface(javax.lang.model.type.TypeMirror typeMirror)
TypeMirror
represents an interface or not.public boolean isClass(javax.lang.model.type.TypeMirror typeMirror)
TypeMirror
represents a class or not.public AnnotationApiHelper.UnwrapMode determineUnwrapMode(javax.lang.model.element.AnnotationMirror annotationMirror)
javax.validation.valueextraction.Unwrapping.Unwrap
,
javax.validation.valueextraction.Unwrapping.Skip
) of constraint.annotationMirror
- constraint annotation mirror under checkAnnotationApiHelper.UnwrapMode.NONE
otherwiseCopyright © 2007-2022 Red Hat, Inc. All Rights Reserved