Package io.smallrye.openapi.runtime.util
Class Annotations
- java.lang.Object
-
- io.smallrye.openapi.runtime.util.Annotations
-
public final class Annotations extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Enum<T>>
TenumValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName, Class<T> clazz)Reads a String property value from the given annotation instance.static org.jboss.jandex.AnnotationInstancegetAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, Collection<org.jboss.jandex.DotName> annotationNames)static org.jboss.jandex.AnnotationInstancegetAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, org.jboss.jandex.DotName annotationName)static Collection<org.jboss.jandex.AnnotationInstance>getAnnotations(org.jboss.jandex.AnnotationTarget target)static <T> TgetAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames)Convenience method to retrieve the "value" parameter from an annotation bound to the target.static <T> TgetAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames, String propertyName)static <T> TgetAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames, String propertyName, T defaultValue)Convenience method to retrieve the named parameter from an annotation bound to the target.static <T> TgetAnnotationValue(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName annotationName, String propertyName)Convenience method to retrieve the named parameter from an annotation bound to the target.static org.jboss.jandex.AnnotationInstancegetDeclaredAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName name)static <T> TgetDeclaredAnnotationValue(org.jboss.jandex.AnnotationTarget type, org.jboss.jandex.DotName annotationName)static <T> TgetDeclaredAnnotationValue(org.jboss.jandex.AnnotationTarget type, org.jboss.jandex.DotName annotationName, String propertyName)static org.jboss.jandex.AnnotationInstancegetMethodParameterAnnotation(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.Returns null if not found.static org.jboss.jandex.AnnotationInstancegetMethodParameterAnnotation(org.jboss.jandex.MethodInfo method, org.jboss.jandex.Type parameterType, org.jboss.jandex.DotName annotationName)Finds an annotation (if present) with the given name, on a particular parameter of a method based on the identity of the parameterType.static List<org.jboss.jandex.AnnotationInstance>getMethodParameterAnnotations(org.jboss.jandex.MethodInfo method, org.jboss.jandex.Type parameterType)Finds all annotations on a particular parameter of a method based on the identity of the parameterType.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 booleanhasAnnotation(org.jboss.jandex.AnnotationTarget target, Collection<org.jboss.jandex.DotName> annotationNames)static booleanhasAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName annotationName)static <T> Tvalue(org.jboss.jandex.AnnotationInstance annotation)static <T> Tvalue(org.jboss.jandex.AnnotationInstance annotation, String name)Convenience method to retrieve the named parameter from an annotation.static <T> Tvalue(org.jboss.jandex.AnnotationInstance annotation, String name, T defaultValue)Convenience method to retrieve the named parameter from an annotation.
-
-
-
Method Detail
-
getAnnotations
public static Collection<org.jboss.jandex.AnnotationInstance> getAnnotations(org.jboss.jandex.AnnotationTarget target)
-
getDeclaredAnnotation
public static org.jboss.jandex.AnnotationInstance getDeclaredAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName name)
-
value
public static <T> T value(org.jboss.jandex.AnnotationInstance annotation)
-
value
public static <T> T value(org.jboss.jandex.AnnotationInstance annotation, String name)Convenience method to retrieve the named parameter from an annotation. The value will be unwrapped from its containingAnnotationValue.- Type Parameters:
T- the type of the parameter being retrieved- Parameters:
annotation- the annotation from which to fetch the parametername- the name of the parameter- Returns:
- an unwrapped annotation parameter value
-
value
public static <T> T value(org.jboss.jandex.AnnotationInstance annotation, String name, T defaultValue)Convenience method to retrieve the named parameter from an annotation. The value will be unwrapped from its containingAnnotationValue.- Type Parameters:
T- the type of the parameter being retrieved- Parameters:
annotation- the annotation from which to fetch the parametername- the name of the parameterdefaultValue- a default value to return if the parameter is not defined- Returns:
- an unwrapped annotation parameter value
-
enumValue
public static <T extends Enum<T>> T enumValue(org.jboss.jandex.AnnotationInstance annotation, String propertyName, Class<T> clazz)
Reads a String property value from the given annotation instance. If no value is found this will return null.- Type Parameters:
T- Type parameter- Parameters:
annotation- AnnotationInstancepropertyName- Stringclazz- Class type of the Enum- Returns:
- Value of property
-
getParameterAnnotations
public 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.- Parameters:
method- MethodInfoparamPosition- parameter position- Returns:
- List of AnnotationInstance's
-
getRepeatableAnnotation
public 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. This method will look for both and return a list of all found. Both the single and wrapper annotation names must be provided.- Parameters:
target- the annotated target (e.g. ClassInfo, MethodInfo)singleAnnotationName- DotNamerepeatableAnnotationName- DotName- Returns:
- List of AnnotationInstance's
-
getMethodParameterAnnotation
public 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.Returns null if not found.- Parameters:
method- the methodparameterIndex- the parameter indexannotationName- name of annotation we are looking for- Returns:
- the Annotation instance
-
getMethodParameterAnnotation
public static org.jboss.jandex.AnnotationInstance getMethodParameterAnnotation(org.jboss.jandex.MethodInfo method, org.jboss.jandex.Type parameterType, org.jboss.jandex.DotName annotationName)Finds an annotation (if present) with the given name, on a particular parameter of a method based on the identity of the parameterType. Returns null if not found.- Parameters:
method- the methodparameterType- the parameter typeannotationName- name of annotation we are looking for- Returns:
- the Annotation instance
-
getMethodParameterAnnotations
public static List<org.jboss.jandex.AnnotationInstance> getMethodParameterAnnotations(org.jboss.jandex.MethodInfo method, org.jboss.jandex.Type parameterType)
Finds all annotations on a particular parameter of a method based on the identity of the parameterType.- Parameters:
method- the methodparameterType- the parameter type- Returns:
- the list of annotations, never null
-
hasAnnotation
public static boolean hasAnnotation(org.jboss.jandex.AnnotationTarget target, Collection<org.jboss.jandex.DotName> annotationNames)
-
hasAnnotation
public static boolean hasAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName annotationName)
-
getAnnotation
public static org.jboss.jandex.AnnotationInstance getAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, org.jboss.jandex.DotName annotationName)
-
getAnnotation
public static org.jboss.jandex.AnnotationInstance getAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, Collection<org.jboss.jandex.DotName> annotationNames)
-
getAnnotationValue
public static <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames)Convenience method to retrieve the "value" parameter from an annotation bound to the target. The value will be unwrapped from its containingAnnotationValue.- Type Parameters:
T- the type of the parameter being retrieved- Parameters:
target- the target object annotated with the annotation named by annotationNameannotationNames- names of annotations from which to retrieve the value- Returns:
- an unwrapped annotation parameter value
-
getAnnotationValue
public static <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName annotationName, String propertyName)Convenience method to retrieve the named parameter from an annotation bound to the target. The value will be unwrapped from its containingAnnotationValue.- Type Parameters:
T- the type of the parameter being retrieved- Parameters:
target- the target object annotated with the annotation named by annotationNameannotationName- name of the annotation from which to retrieve the valuepropertyName- the name of the parameter/property in the annotation- Returns:
- an unwrapped annotation parameter value
-
getAnnotationValue
public static <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames, String propertyName)
-
getAnnotationValue
public static <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames, String propertyName, T defaultValue)Convenience method to retrieve the named parameter from an annotation bound to the target. The value will be unwrapped from its containingAnnotationValue.- Type Parameters:
T- the type of the parameter being retrieved- Parameters:
target- the target object annotated with the annotation named by annotationNameannotationNames- names of the annotations from which to retrieve the valuepropertyName- the name of the parameter/property in the annotationdefaultValue- a default value to return if either the annotation or the value are missing- Returns:
- an unwrapped annotation parameter value
-
getDeclaredAnnotationValue
public static <T> T getDeclaredAnnotationValue(org.jboss.jandex.AnnotationTarget type, org.jboss.jandex.DotName annotationName, String propertyName)
-
getDeclaredAnnotationValue
public static <T> T getDeclaredAnnotationValue(org.jboss.jandex.AnnotationTarget type, org.jboss.jandex.DotName annotationName)
-
-