public class JandexUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
JandexUtil.RefType
Simple enum to indicate the type of a $ref being read/written.
|
Modifier and Type | Method and Description |
---|---|
static BigDecimal |
bigDecimalValue(org.jboss.jandex.AnnotationInstance annotation,
String propertyName)
Reads a Double property value from the given annotation instance.
|
static Boolean |
booleanValue(org.jboss.jandex.AnnotationInstance annotation,
String propertyName)
Reads a Boolean property value from the given annotation instance.
|
static boolean |
booleanValueWithDefault(org.jboss.jandex.AnnotationInstance annotation,
String propertyName)
Reads a Boolean property from the given annotation instance.
|
static <T extends Enum<?>> |
enumValue(org.jboss.jandex.AnnotationInstance annotation,
String propertyName,
Class<T> clazz)
Reads a String property value from the given annotation instance.
|
static <T extends Enum<?>> |
enumValue(String strVal,
Class<T> clazz)
Converts a string value to the given enum type.
|
static org.jboss.jandex.AnnotationInstance |
getClassAnnotation(org.jboss.jandex.ClassInfo ct,
org.jboss.jandex.DotName name)
Gets a single class annotation from the given class.
|
static Collection<org.jboss.jandex.ClassInfo> |
getJaxRsResourceClasses(org.jboss.jandex.IndexView index)
Use the Jandex index to find all jax-rs resource classes.
|
static org.jboss.jandex.AnnotationInstance |
getMethodParameterAnnotation(org.jboss.jandex.MethodInfo method,
int parameterIndex,
org.jboss.jandex.DotName annotationName)
Finds an annotation (if present) with the given name, on a particular parameter of a
method.
|
static org.jboss.jandex.Type |
getMethodParameterType(org.jboss.jandex.MethodInfo method,
short position)
Returns the class type of the method parameter at the given position.
|
static org.jboss.jandex.Type |
getMethodParameterType(org.jboss.jandex.MethodParameterInfo parameter)
Returns the class type of the method parameter.
|
static List<org.jboss.jandex.AnnotationInstance> |
getParameterAnnotations(org.jboss.jandex.MethodInfo method,
short paramPosition)
Returns all annotations configured for a single parameter of a method.
|
static List<org.jboss.jandex.AnnotationInstance> |
getRepeatableAnnotation(org.jboss.jandex.AnnotationTarget target,
org.jboss.jandex.DotName singleAnnotationName,
org.jboss.jandex.DotName repeatableAnnotationName)
Many OAI annotations can either be found singly or as a wrapped array.
|
static org.jboss.jandex.Type |
getRequestBodyParameterClassType(org.jboss.jandex.MethodInfo method,
List<AnnotationScannerExtension> extensions)
Go through the method parameters looking for one that is not annotated with a jax-rs
annotation.
|
static boolean |
hasImplementation(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given
@Schema
annotation has defined an "implementation" field. |
static Map<org.jboss.jandex.ClassInfo,org.jboss.jandex.Type> |
inheritanceChain(org.jboss.jandex.IndexView index,
org.jboss.jandex.ClassInfo klazz,
org.jboss.jandex.Type type)
Builds an insertion-order map of a class's inheritance chain, starting
with the klazz argument.
|
static Integer |
intValue(org.jboss.jandex.AnnotationInstance annotation,
String propertyName)
Reads a Integer property value from the given annotation instance.
|
static boolean |
isArraySchema(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given
@Schema
annotation is an array schema. |
static boolean |
isEmpty(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given annotation is void of any values (and thus is "empty").
|
static boolean |
isRef(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given annotation instance is a "ref".
|
static boolean |
isSimpleArraySchema(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given @Schema annotation is a simple array schema.
|
static boolean |
isSimpleClassSchema(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given @Schema annotation is a simple class schema.
|
static String |
nameFromRef(org.jboss.jandex.AnnotationInstance annotation)
Gets the name of an item from its ref.
|
static String |
refValue(org.jboss.jandex.AnnotationInstance annotation,
JandexUtil.RefType refType)
Reads a string property named "ref" value from the given annotation and converts it
to a value appropriate for setting on a model's "$ref" property.
|
static List<String> |
stringListValue(org.jboss.jandex.AnnotationInstance annotation,
String propertyName)
Reads a String array property value from the given annotation instance.
|
static String |
stringValue(org.jboss.jandex.AnnotationInstance annotation,
String propertyName)
Reads a String property value from the given annotation instance.
|
static <T> T |
value(org.jboss.jandex.AnnotationInstance annotation,
String name)
Convenience method to retrieve the named parameter from an annotation.
|
public static String refValue(org.jboss.jandex.AnnotationInstance annotation, JandexUtil.RefType refType)
annotation
- AnnotationInstancerefType
- RefTypepublic static <T> T value(org.jboss.jandex.AnnotationInstance annotation, String name)
AnnotationValue
.T
- the type of the parameter being retrievedannotation
- the annotation from which to fetch the parametername
- the name of the parameterpublic static String stringValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
annotation
- AnnotationInstancepropertyName
- Stringpublic static Boolean booleanValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
annotation
- AnnotationInstancepropertyName
- Stringpublic static boolean booleanValueWithDefault(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
annotation
- AnnotationInstancepropertyName
- Stringpublic static BigDecimal bigDecimalValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
annotation
- AnnotationInstancepropertyName
- Stringpublic static Integer intValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
annotation
- AnnotationInstancepropertyName
- Stringpublic static List<String> stringListValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName)
annotation
- AnnotationInstancepropertyName
- Stringpublic static <T extends Enum<?>> T enumValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName, Class<T> clazz)
T
- Type parameterannotation
- AnnotationInstancepropertyName
- Stringclazz
- Class type of the Enumpublic static <T extends Enum<?>> T enumValue(String strVal, Class<T> clazz)
T
- Type parameterstrVal
- Stringclazz
- Class type of the Enumpublic static boolean isRef(org.jboss.jandex.AnnotationInstance annotation)
annotation
- AnnotationInstancepublic static boolean isEmpty(org.jboss.jandex.AnnotationInstance annotation)
annotation
- AnnotationInstancepublic static org.jboss.jandex.AnnotationInstance getClassAnnotation(org.jboss.jandex.ClassInfo ct, org.jboss.jandex.DotName name)
ct
- ClassInfoname
- DotNamepublic static Collection<org.jboss.jandex.ClassInfo> getJaxRsResourceClasses(org.jboss.jandex.IndexView index)
index
- IndexViewpublic static List<org.jboss.jandex.AnnotationInstance> getParameterAnnotations(org.jboss.jandex.MethodInfo method, short paramPosition)
method
- MethodInfoparamPosition
- parameter positionpublic static String nameFromRef(org.jboss.jandex.AnnotationInstance annotation)
annotation
- AnnotationInstancepublic static List<org.jboss.jandex.AnnotationInstance> getRepeatableAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName singleAnnotationName, org.jboss.jandex.DotName repeatableAnnotationName)
target
- the annotated target (e.g. ClassInfo, MethodInfo)singleAnnotationName
- DotNamerepeatableAnnotationName
- DotNamepublic static org.jboss.jandex.Type getMethodParameterType(org.jboss.jandex.MethodInfo method, short position)
method
- MethodInfoposition
- parameter positionpublic static org.jboss.jandex.Type getMethodParameterType(org.jboss.jandex.MethodParameterInfo parameter)
parameter
- the parameter
public static org.jboss.jandex.Type getRequestBodyParameterClassType(org.jboss.jandex.MethodInfo method, List<AnnotationScannerExtension> extensions)
method
- MethodInfoextensions
- available extensionspublic static org.jboss.jandex.AnnotationInstance getMethodParameterAnnotation(org.jboss.jandex.MethodInfo method, int parameterIndex, org.jboss.jandex.DotName annotationName)
method
- parameterIndex
- annotationName
- public static boolean isSimpleClassSchema(org.jboss.jandex.AnnotationInstance annotation)
annotation
- AnnotationInstancepublic static boolean isSimpleArraySchema(org.jboss.jandex.AnnotationInstance annotation)
annotation
- AnnotationInstancepublic static boolean isArraySchema(org.jboss.jandex.AnnotationInstance annotation)
@Schema
annotation is an array schema. This is defined as a schema with a "type" field and "implementation"
field defined *and* the type must be array.annotation
- AnnotationInstance@Schema
public static boolean hasImplementation(org.jboss.jandex.AnnotationInstance annotation)
@Schema
annotation has defined an "implementation" field.annotation
- AnnotationInstancepublic static Map<org.jboss.jandex.ClassInfo,org.jboss.jandex.Type> inheritanceChain(org.jboss.jandex.IndexView index, org.jboss.jandex.ClassInfo klazz, org.jboss.jandex.Type type)
index
- index for superclass retrievalklazz
- the class to retrieve inheritancetype
- type of the klazzCopyright © 2018–2020. All rights reserved.