Package org.hibernate.jpamodelgen.util
Class TypeUtils
- java.lang.Object
-
- org.hibernate.jpamodelgen.util.TypeUtils
-
public final class TypeUtils extends Object
Utility class.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_ANNOTATION_PARAMETER_NAME
static Set<String>
PRIMITIVE_TYPES
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
containsAnnotation(Element element, String... annotations)
static void
determineAccessTypeForHierarchy(TypeElement searchedElement, Context context)
static @Nullable AccessType
determineAnnotationSpecifiedAccessType(Element element)
static @Nullable TypeMirror
extractClosestRealType(TypeMirror type, Context context)
static String
extractClosestRealTypeAsString(TypeMirror type, Context context)
static @Nullable AnnotationMirror
getAnnotationMirror(Element element, String qualifiedName)
Checks whether theElement
hosts the annotation with the given fully qualified class name.static @Nullable Object
getAnnotationValue(AnnotationMirror annotationMirror, String parameterValue)
static @Nullable AnnotationValue
getAnnotationValueRef(AnnotationMirror annotationMirror, String parameterValue)
static TypeMirror
getCollectionElementType(DeclaredType t, String fqNameOfReturnedType, @Nullable String explicitTargetEntityName, Context context)
static ElementKind
getElementKindForAccessType(AccessType accessType)
static String
getKeyType(DeclaredType type, Context context)
static @Nullable TypeElement
getSuperclassTypeElement(TypeElement element)
static boolean
hasAnnotation(Element element, String qualifiedName)
static boolean
isAnnotationMirrorOfType(AnnotationMirror annotationMirror, String qualifiedName)
Returnstrue
if the provided annotation type is of the same type as the provided class,false
otherwise.static boolean
isClassOrRecordType(Element element)
static boolean
isPrimitive(String paramType)
static String
toArrayTypeString(ArrayType type, Context context)
static String
toTypeString(TypeMirror type)
-
-
-
Field Detail
-
DEFAULT_ANNOTATION_PARAMETER_NAME
public static final String DEFAULT_ANNOTATION_PARAMETER_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
toTypeString
public static String toTypeString(TypeMirror type)
-
getSuperclassTypeElement
public static @Nullable TypeElement getSuperclassTypeElement(TypeElement element)
-
extractClosestRealTypeAsString
public static String extractClosestRealTypeAsString(TypeMirror type, Context context)
-
extractClosestRealType
public static @Nullable TypeMirror extractClosestRealType(TypeMirror type, Context context)
-
containsAnnotation
public static boolean containsAnnotation(Element element, String... annotations)
-
isAnnotationMirrorOfType
public static boolean isAnnotationMirrorOfType(AnnotationMirror annotationMirror, String qualifiedName)
Returnstrue
if the provided annotation type is of the same type as the provided class,false
otherwise. This method uses the string class names for comparison. See also getting-class-values-from-annotations.- Parameters:
annotationMirror
- The annotation mirrorqualifiedName
- the fully qualified class name to check against- Returns:
true
if the provided annotation type is of the same type as the provided class,false
otherwise.
-
getAnnotationMirror
public static @Nullable AnnotationMirror getAnnotationMirror(Element element, String qualifiedName)
Checks whether theElement
hosts the annotation with the given fully qualified class name.- Parameters:
element
- the element to check for the hosted annotationqualifiedName
- the fully qualified class name of the annotation to check for- Returns:
- the annotation mirror for the specified annotation class from the
Element
ornull
in case theTypeElement
does not host the specified annotation.
-
getAnnotationValue
public static @Nullable Object getAnnotationValue(AnnotationMirror annotationMirror, String parameterValue)
-
getAnnotationValueRef
public static @Nullable AnnotationValue getAnnotationValueRef(AnnotationMirror annotationMirror, String parameterValue)
-
determineAccessTypeForHierarchy
public static void determineAccessTypeForHierarchy(TypeElement searchedElement, Context context)
-
getCollectionElementType
public static TypeMirror getCollectionElementType(DeclaredType t, String fqNameOfReturnedType, @Nullable String explicitTargetEntityName, Context context)
-
determineAnnotationSpecifiedAccessType
public static @Nullable AccessType determineAnnotationSpecifiedAccessType(Element element)
-
getElementKindForAccessType
public static ElementKind getElementKindForAccessType(AccessType accessType)
-
getKeyType
public static String getKeyType(DeclaredType type, Context context)
-
isClassOrRecordType
public static boolean isClassOrRecordType(Element element)
-
isPrimitive
public static boolean isPrimitive(String paramType)
-
-