Class Annotations

java.lang.Object
io.smallrye.openapi.runtime.util.Annotations

public final class Annotations extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends Enum<T>>
    T
    enumValue(Class<T> clazz, String value)
     
    <T extends Enum<T>>
    T
    enumValue(Class<T> clazz, org.jboss.jandex.AnnotationValue value)
     
    <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.
    org.jboss.jandex.AnnotationInstance
    getAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, Collection<org.jboss.jandex.DotName> annotationNames)
     
    org.jboss.jandex.AnnotationInstance
    getAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, org.jboss.jandex.DotName... annotationName)
     
    <T> T
    getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames)
     
    <T> T
    getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames, String propertyName)
     
    <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.
    <T> T
    getAnnotationValue(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName... annotationNames)
    Convenience method to retrieve the "value" parameter from an annotation bound to the target.
    <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.
    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.
    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.
    List<org.jboss.jandex.AnnotationInstance>
    getMethodParameterAnnotations(org.jboss.jandex.MethodInfo method, int parameterIndex)
    Returns all annotations configured for a single parameter of a method.
    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.
    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.
    boolean
    hasAnnotation(org.jboss.jandex.AnnotationTarget target, Collection<org.jboss.jandex.DotName> annotationNames)
     
    boolean
    hasAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName... annotationNames)
     
    <T> T
    value(org.jboss.jandex.AnnotationInstance annotation)
     
    <T> T
    value(org.jboss.jandex.AnnotationInstance annotation, String name)
    Convenience method to retrieve the named parameter from an annotation.
    <T> T
    value(org.jboss.jandex.AnnotationInstance annotation, String name, T defaultValue)
    Convenience method to retrieve the named parameter from an annotation.
    <T> T
    value(org.jboss.jandex.AnnotationInstance annotation, org.jboss.jandex.AnnotationValue value)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • value

      public <T> T value(org.jboss.jandex.AnnotationInstance annotation)
    • value

      public <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 containing AnnotationValue.
      Type Parameters:
      T - the type of the parameter being retrieved
      Parameters:
      annotation - the annotation from which to fetch the parameter
      name - the name of the parameter
      Returns:
      an unwrapped annotation parameter value
    • value

      public <T> T value(org.jboss.jandex.AnnotationInstance annotation, org.jboss.jandex.AnnotationValue value)
    • value

      public <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 containing AnnotationValue.
      Type Parameters:
      T - the type of the parameter being retrieved
      Parameters:
      annotation - the annotation from which to fetch the parameter
      name - the name of the parameter
      defaultValue - a default value to return if the parameter is not defined
      Returns:
      an unwrapped annotation parameter value
    • enumValue

      public <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 - AnnotationInstance
      propertyName - String
      clazz - Class type of the Enum
      Returns:
      Value of property
    • enumValue

      public <T extends Enum<T>> T enumValue(Class<T> clazz, org.jboss.jandex.AnnotationValue value)
    • enumValue

      public <T extends Enum<T>> T enumValue(Class<T> clazz, String value)
    • getRepeatableAnnotation

      public 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 - DotName
      repeatableAnnotationName - DotName
      Returns:
      List of AnnotationInstance's
    • getMethodParameterAnnotation

      public 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 method
      parameterIndex - the parameter index
      annotationName - name of annotation we are looking for
      Returns:
      the Annotation instance
    • getMethodParameterAnnotation

      public 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 method
      parameterType - the parameter type
      annotationName - name of annotation we are looking for
      Returns:
      the Annotation instance
    • getMethodParameterAnnotations

      public List<org.jboss.jandex.AnnotationInstance> getMethodParameterAnnotations(org.jboss.jandex.MethodInfo method, int parameterIndex)
      Returns all annotations configured for a single parameter of a method.
      Parameters:
      method - MethodInfo
      parameterIndex - parameter position
      Returns:
      List of AnnotationInstance's
    • getMethodParameterAnnotations

      public 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 method
      parameterType - the parameter type
      Returns:
      the list of annotations, never null
    • hasAnnotation

      public boolean hasAnnotation(org.jboss.jandex.AnnotationTarget target, Collection<org.jboss.jandex.DotName> annotationNames)
    • hasAnnotation

      public boolean hasAnnotation(org.jboss.jandex.AnnotationTarget target, org.jboss.jandex.DotName... annotationNames)
    • getAnnotation

      public org.jboss.jandex.AnnotationInstance getAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, org.jboss.jandex.DotName... annotationName)
    • getAnnotation

      public org.jboss.jandex.AnnotationInstance getAnnotation(org.jboss.jandex.AnnotationTarget annotationTarget, Collection<org.jboss.jandex.DotName> annotationNames)
    • getAnnotationValue

      public <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, 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 containing AnnotationValue.
      Type Parameters:
      T - the type of the parameter being retrieved
      Parameters:
      target - the target object annotated with the annotation named by annotationName
      annotationNames - names of annotations from which to retrieve the value
      Returns:
      an unwrapped annotation parameter value
    • getAnnotationValue

      public <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames)
    • getAnnotationValue

      public <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 containing AnnotationValue.
      Type Parameters:
      T - the type of the parameter being retrieved
      Parameters:
      target - the target object annotated with the annotation named by annotationName
      annotationName - name of the annotation from which to retrieve the value
      propertyName - the name of the parameter/property in the annotation
      Returns:
      an unwrapped annotation parameter value
    • getAnnotationValue

      public <T> T getAnnotationValue(org.jboss.jandex.AnnotationTarget target, List<org.jboss.jandex.DotName> annotationNames, String propertyName)
    • getAnnotationValue

      public <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 containing AnnotationValue.
      Type Parameters:
      T - the type of the parameter being retrieved
      Parameters:
      target - the target object annotated with the annotation named by annotationName
      annotationNames - names of the annotations from which to retrieve the value
      propertyName - the name of the parameter/property in the annotation
      defaultValue - a default value to return if either the annotation or the value are missing
      Returns:
      an unwrapped annotation parameter value