Class TypeUtils
java.lang.Object
org.hibernate.processor.util.TypeUtils
Utility class.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsAnnotation(Element element, String... annotations) static voiddetermineAccessTypeForHierarchy(TypeElement searchedElement, Context context) static @Nullable AccessTypestatic booleanextendsClass(TypeElement type, String className) static @Nullable TypeMirrorextractClosestRealType(TypeMirror type, Context context, Set<TypeVariable> beingVisited) static StringextractClosestRealTypeAsString(TypeMirror type, Context context) static @Nullable ElementfindMappedSuperElement(Metamodel entity, Context context) static @Nullable AnnotationMirrorgetAnnotationMirror(Element element, String qualifiedName) Checks whether theElementhosts the annotation with the given fully qualified class name.static @Nullable AnnotationValuegetAnnotationValue(AnnotationMirror annotationMirror) static @Nullable AnnotationValuegetAnnotationValue(AnnotationMirror annotationMirror, String member) static TypeMirrorgetCollectionElementType(DeclaredType type, String returnTypeName, @Nullable String explicitTargetEntityName, Context context) static ElementKindgetElementKindForAccessType(AccessType accessType) static @Nullable StringgetFullyQualifiedClassNameOfTargetEntity(AnnotationMirror mirror, String member) static StringgetGeneratedClassFullyQualifiedName(TypeElement typeElement, boolean jakartaDataStyle) static StringgetGeneratedClassFullyQualifiedName(TypeElement element, String packageName, boolean jakartaDataStyle) static @Nullable AnnotationMirrorgetInheritedAnnotationMirror(Elements elements, Element element, String qualifiedName) Checks whether theElementhosts the annotation (directly or inherited) with the given fully qualified class name.static StringgetKeyType(DeclaredType type, Context context) static @Nullable TypeElementgetSuperclassTypeElement(TypeElement element) static @Nullable StringgetTargetEntity(List<? extends AnnotationMirror> annotations) static booleanhasAnnotation(Element element, String qualifiedName) static booleanhasAnnotation(Element element, String... qualifiedNames) static booleanimplementsInterface(TypeElement type, String interfaceName) static booleanisAnnotationMirrorOfType(AnnotationMirror annotationMirror, String qualifiedName) Returnstrueif the provided annotation type is of the same type as the provided class,falseotherwise.static booleanisClassOrRecordType(Element element) static booleanisClassRecordOrInterfaceType(Element element) static booleanisMemberType(Element element) static booleanisPluralAttribute(Element element) static booleanisPrimitive(String paramType) static booleanisPropertyGetter(ExecutableType executable, Element element) static booleanprimitiveClassMatchesKind(Class<?> itemType, TypeKind kind) static StringpropertyName(Element element) static @Nullable TypeMirrorresolveTypeMirror(TypeElement typeElement, Element element, String name) static StringresolveTypeName(TypeElement typeElement, Element element, String name) static StringtoArrayTypeString(ArrayType type, Context context) static StringtoTypeString(TypeMirror type)
-
Field Details
-
DEFAULT_ANNOTATION_PARAMETER_NAME
- See Also:
-
PRIMITIVE_TYPES
-
-
Method Details
-
toTypeString
-
toArrayTypeString
-
getSuperclassTypeElement
-
extractClosestRealTypeAsString
-
extractClosestRealType
public static @Nullable TypeMirror extractClosestRealType(TypeMirror type, Context context, Set<TypeVariable> beingVisited) -
containsAnnotation
-
isAnnotationMirrorOfType
public static boolean isAnnotationMirrorOfType(AnnotationMirror annotationMirror, String qualifiedName) Returnstrueif the provided annotation type is of the same type as the provided class,falseotherwise. 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:
trueif the provided annotation type is of the same type as the provided class,falseotherwise.
-
getAnnotationMirror
Checks whether theElementhosts 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
Elementornullin case theTypeElementdoes not host the specified annotation.
-
getInheritedAnnotationMirror
public static @Nullable AnnotationMirror getInheritedAnnotationMirror(Elements elements, Element element, String qualifiedName) Checks whether theElementhosts the annotation (directly or inherited) 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
Elementornullin case theTypeElementdoes not host the specified annotation (directly or inherited).
-
hasAnnotation
-
hasAnnotation
-
getAnnotationValue
-
getAnnotationValue
public static @Nullable AnnotationValue getAnnotationValue(AnnotationMirror annotationMirror, String member) -
determineAccessTypeForHierarchy
-
getCollectionElementType
public static TypeMirror getCollectionElementType(DeclaredType type, String returnTypeName, @Nullable String explicitTargetEntityName, Context context) -
determineAnnotationSpecifiedAccessType
-
getElementKindForAccessType
-
getKeyType
-
isClassOrRecordType
-
isClassRecordOrInterfaceType
-
primitiveClassMatchesKind
-
isPropertyGetter
-
isPluralAttribute
-
getFullyQualifiedClassNameOfTargetEntity
public static @Nullable String getFullyQualifiedClassNameOfTargetEntity(AnnotationMirror mirror, String member) -
getTargetEntity
- Parameters:
annotations- list of annotation mirrors.- Returns:
- target entity class name as string or
nullif no targetEntity is here or if equals to void
-
propertyName
-
findMappedSuperElement
-
implementsInterface
-
extendsClass
-
isMemberType
-
getGeneratedClassFullyQualifiedName
public static String getGeneratedClassFullyQualifiedName(TypeElement typeElement, boolean jakartaDataStyle) -
getGeneratedClassFullyQualifiedName
public static String getGeneratedClassFullyQualifiedName(TypeElement element, String packageName, boolean jakartaDataStyle) -
isPrimitive
-
resolveTypeName
-
resolveTypeMirror
public static @Nullable TypeMirror resolveTypeMirror(TypeElement typeElement, Element element, String name)
-