Package io.smallrye.openapi.runtime.util
Class JandexUtil
- java.lang.Object
-
- io.smallrye.openapi.runtime.util.JandexUtil
-
public class JandexUtil extends Object
Some utility methods for working with Jandex objects.- Author:
- eric.wittmann@gmail.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJandexUtil.RefTypeSimple enum to indicate the type of a $ref being read/written.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcreateUniqueAnnotationTargetRef(org.jboss.jandex.AnnotationTarget annotationTarget)static StringcreateUniqueFieldRef(org.jboss.jandex.FieldInfo fieldInfo)static StringcreateUniqueMethodParameterRef(org.jboss.jandex.MethodParameterInfo methodParameter)static StringcreateUniqueMethodReference(org.jboss.jandex.ClassInfo classInfo, org.jboss.jandex.MethodInfo methodInfo)static booleanequals(org.jboss.jandex.AnnotationTarget t1, org.jboss.jandex.AnnotationTarget t2)static booleanequals(org.jboss.jandex.ClassInfo c1, org.jboss.jandex.ClassInfo c2)static booleanequals(org.jboss.jandex.FieldInfo f1, org.jboss.jandex.FieldInfo f2)static booleanequals(org.jboss.jandex.MethodParameterInfo p1, org.jboss.jandex.MethodParameterInfo p2)static List<org.jboss.jandex.FieldInfo>fields(AnnotationScannerContext context, org.jboss.jandex.ClassInfo currentClass)static booleanhasImplementation(org.jboss.jandex.AnnotationInstance annotation)Returns true if the given@Schemaannotation has defined an "implementation" field.static booleanisArraySchema(org.jboss.jandex.AnnotationInstance annotation)Returns true if the given@Schemaannotation is an array schema.static booleanisEmpty(org.jboss.jandex.AnnotationInstance annotation)Returns true if the given annotation is void of any values (and thus is "empty").static booleanisRef(org.jboss.jandex.AnnotationInstance annotation)Returns true if the given annotation instance is a "ref".static booleanisSimpleArraySchema(org.jboss.jandex.AnnotationInstance annotation)Returns true if the given @Schema annotation is a simple array schema.static booleanisSimpleClassSchema(org.jboss.jandex.AnnotationInstance annotation)Returns true if the given @Schema annotation is a simple class schema.static booleanisSupplier(org.jboss.jandex.AnnotationTarget target)static StringnameFromRef(org.jboss.jandex.AnnotationInstance annotation)Gets the name of an item from its ref.static StringrefValue(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<org.jboss.jandex.AnnotationValue>schemaDisplayValues(org.jboss.jandex.AnnotationInstance annotation)
-
-
-
Method Detail
-
createUniqueAnnotationTargetRef
public static String createUniqueAnnotationTargetRef(org.jboss.jandex.AnnotationTarget annotationTarget)
-
createUniqueFieldRef
public static String createUniqueFieldRef(org.jboss.jandex.FieldInfo fieldInfo)
-
createUniqueMethodReference
public static String createUniqueMethodReference(org.jboss.jandex.ClassInfo classInfo, org.jboss.jandex.MethodInfo methodInfo)
-
createUniqueMethodParameterRef
public static String createUniqueMethodParameterRef(org.jboss.jandex.MethodParameterInfo methodParameter)
-
refValue
public 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.- Parameters:
annotation- AnnotationInstancerefType- RefType- Returns:
- String value
-
isRef
public static boolean isRef(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given annotation instance is a "ref". An annotation is a ref if it has a non-null value for the "ref" property.- Parameters:
annotation- AnnotationInstance- Returns:
- Whether it's a "ref"
-
isEmpty
public static boolean isEmpty(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given annotation is void of any values (and thus is "empty"). An example of this would be if a jax-rs method were annotated with @Tag()- Parameters:
annotation- AnnotationInstance- Returns:
- Whether it's empty
-
nameFromRef
public static String nameFromRef(org.jboss.jandex.AnnotationInstance annotation)
Gets the name of an item from its ref. For example, the ref might be "#/components/parameters/departureDate" which would result in a name of "departureDate".- Parameters:
annotation- AnnotationInstance- Returns:
- Name of item from ref
-
schemaDisplayValues
public static List<org.jboss.jandex.AnnotationValue> schemaDisplayValues(org.jboss.jandex.AnnotationInstance annotation)
-
isSimpleClassSchema
public static boolean isSimpleClassSchema(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given @Schema annotation is a simple class schema. This means that the annotation only has one field defined, and that field is "implementation".- Parameters:
annotation- AnnotationInstance- Returns:
- Is it a simple class @Schema
-
isSimpleArraySchema
public static boolean isSimpleArraySchema(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given @Schema annotation is a simple array schema. This is defined as a schema with only a "type" field and "implementation" field defined *and* the type must be array.- Parameters:
annotation- AnnotationInstance- Returns:
- Is it a simple array @Schema
-
isArraySchema
public static boolean isArraySchema(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given@Schemaannotation is an array schema. This is defined as a schema with a "type" field and "implementation" field defined *and* the type must be array.- Parameters:
annotation- AnnotationInstance- Returns:
- Is it an array
@Schema
-
hasImplementation
public static boolean hasImplementation(org.jboss.jandex.AnnotationInstance annotation)
Returns true if the given@Schemaannotation has defined an "implementation" field.- Parameters:
annotation- AnnotationInstance- Returns:
- true if the annotation defines an implementation, otherwise false
-
equals
public static boolean equals(org.jboss.jandex.AnnotationTarget t1, org.jboss.jandex.AnnotationTarget t2)
-
equals
public static boolean equals(org.jboss.jandex.ClassInfo c1, org.jboss.jandex.ClassInfo c2)
-
equals
public static boolean equals(org.jboss.jandex.FieldInfo f1, org.jboss.jandex.FieldInfo f2)
-
equals
public static boolean equals(org.jboss.jandex.MethodParameterInfo p1, org.jboss.jandex.MethodParameterInfo p2)
-
fields
public static List<org.jboss.jandex.FieldInfo> fields(AnnotationScannerContext context, org.jboss.jandex.ClassInfo currentClass)
-
isSupplier
public static boolean isSupplier(org.jboss.jandex.AnnotationTarget target)
-
-