public class JandexHelper extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
containsSingleAnnotations(Map<org.jboss.jandex.DotName,List<org.jboss.jandex.AnnotationInstance>> annotations,
org.jboss.jandex.DotName annotationName) |
static <T extends Enum<T>> |
getEnumValue(org.jboss.jandex.AnnotationInstance annotation,
String element,
Class<T> type)
Retrieves a jandex annotation element value, converting it to the supplied enumerated type.
|
static Map<org.jboss.jandex.DotName,List<org.jboss.jandex.AnnotationInstance>> |
getMemberAnnotations(org.jboss.jandex.ClassInfo classInfo,
String name) |
static String |
getPropertyName(org.jboss.jandex.AnnotationTarget target)
Expects a method or field annotation target and returns the property name for this target
|
static org.jboss.jandex.AnnotationInstance |
getSingleAnnotation(org.jboss.jandex.ClassInfo classInfo,
org.jboss.jandex.DotName annotationName) |
static org.jboss.jandex.AnnotationInstance |
getSingleAnnotation(Map<org.jboss.jandex.DotName,List<org.jboss.jandex.AnnotationInstance>> annotations,
org.jboss.jandex.DotName annotationName) |
static <T> T |
getValue(org.jboss.jandex.AnnotationInstance annotation,
String element,
Class<T> type)
Retrieves a jandex annotation element value.
|
static <T> T |
getValue(org.jboss.jandex.AnnotationInstance annotation,
String element,
Class<T> type,
ClassLoaderService classLoaderService) |
static org.jboss.jandex.Index |
indexForClass(ClassLoaderService classLoaderService,
Class<?>... classes)
Creates a jandex index for the specified classes
|
public static <T> T getValue(org.jboss.jandex.AnnotationInstance annotation, String element, Class<T> type) throws AssertionFailure
null
, the default value specified in the
annotation class is retrieved instead.
There are two special cases. Class
parameters should be retrieved as strings (and then can later be
loaded) and enumerated values should be retrieved via getEnumValue(AnnotationInstance, String, Class)
.
annotation
- the annotation containing the element with the supplied nameelement
- the name of the element value to be retrievetype
- the type of element to retrieve. The following types are supported:
null
, else the default value if not
null
, else null
.AssertionFailure
- in case the specified type
is a class instance or the specified type causes a ClassCastException
when retrieving the value.public static <T> T getValue(org.jboss.jandex.AnnotationInstance annotation, String element, Class<T> type, ClassLoaderService classLoaderService) throws AssertionFailure
AssertionFailure
public static <T extends Enum<T>> T getEnumValue(org.jboss.jandex.AnnotationInstance annotation, String element, Class<T> type)
null
, the default value specified in the annotation class is retrieved instead.T
- an enumerated typeannotation
- the annotation containing the enumerated element with the supplied nameelement
- the name of the enumerated element value to be retrievetype
- the type to which to convert the value before being returnednull
, else the default value if
not null
, else null
.getValue(AnnotationInstance, String, Class)
public static String getPropertyName(org.jboss.jandex.AnnotationTarget target)
target
- the annotation targetpublic static org.jboss.jandex.AnnotationInstance getSingleAnnotation(org.jboss.jandex.ClassInfo classInfo, org.jboss.jandex.DotName annotationName) throws AssertionFailure
classInfo
- the class info from which to retrieve the annotation instanceannotationName
- the annotation to retrieve from the class infonull
in case the annotation is not specified at allAssertionFailure
- in case there is there is more than one annotation of this type.public static org.jboss.jandex.AnnotationInstance getSingleAnnotation(Map<org.jboss.jandex.DotName,List<org.jboss.jandex.AnnotationInstance>> annotations, org.jboss.jandex.DotName annotationName) throws AssertionFailure
annotations
- List of annotation instances keyed against their dot name.annotationName
- the annotation to retrieve from mapnull
in case the annotation is not specified at allAssertionFailure
- in case there is there is more than one annotation of this type.public static boolean containsSingleAnnotations(Map<org.jboss.jandex.DotName,List<org.jboss.jandex.AnnotationInstance>> annotations, org.jboss.jandex.DotName annotationName) throws AssertionFailure
annotations
- List of annotation instances keyed against their dot name.annotationName
- the annotation to checktrue
if the map contains only a single instance of specified annotation or false
otherwise.AssertionFailure
- in case there is there is more than one annotation of this type.public static org.jboss.jandex.Index indexForClass(ClassLoaderService classLoaderService, Class<?>... classes)
classLoaderService
- class loader serviceclasses
- the classes to indexCopyright © 2001-2015 Red Hat, Inc. All Rights Reserved.