Class TypeUtils


  • public final class TypeUtils
    extends Object
    Utility class.
    • Field Detail

      • PRIMITIVE_TYPES

        public static final Set<String> PRIMITIVE_TYPES
    • Method Detail

      • getSuperclassTypeElement

        public static @Nullable TypeElement getSuperclassTypeElement​(TypeElement element)
      • extractClosestRealTypeAsString

        public static String extractClosestRealTypeAsString​(TypeMirror type,
                                                            Context context)
      • containsAnnotation

        public static boolean containsAnnotation​(Element element,
                                                 String... annotations)
      • isAnnotationMirrorOfType

        public static boolean isAnnotationMirrorOfType​(AnnotationMirror annotationMirror,
                                                       String qualifiedName)
        Returns true 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 mirror
        qualifiedName - 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 the Element hosts the annotation with the given fully qualified class name.
        Parameters:
        element - the element to check for the hosted annotation
        qualifiedName - the fully qualified class name of the annotation to check for
        Returns:
        the annotation mirror for the specified annotation class from the Element or null in case the TypeElement does not host the specified annotation.
      • hasAnnotation

        public static boolean hasAnnotation​(Element element,
                                            String qualifiedName)
      • hasAnnotation

        public static boolean hasAnnotation​(Element element,
                                            String... qualifiedNames)
      • determineAccessTypeForHierarchy

        public static void determineAccessTypeForHierarchy​(TypeElement searchedElement,
                                                           Context context)
      • determineAnnotationSpecifiedAccessType

        public static @Nullable AccessType determineAnnotationSpecifiedAccessType​(Element element)
      • getElementKindForAccessType

        public static ElementKind getElementKindForAccessType​(AccessType accessType)
      • isClassOrRecordType

        public static boolean isClassOrRecordType​(Element element)
      • primitiveClassMatchesKind

        public static boolean primitiveClassMatchesKind​(Class<?> itemType,
                                                        TypeKind kind)
      • isPropertyGetter

        public static boolean isPropertyGetter​(ExecutableType executable,
                                               Element element)
      • isBasicAttribute

        public static boolean isBasicAttribute​(Element element,
                                               Element returnedElement,
                                               Context context)
      • getFullyQualifiedClassNameOfTargetEntity

        public static @Nullable String getFullyQualifiedClassNameOfTargetEntity​(AnnotationMirror mirror,
                                                                                String member)
      • getTargetEntity

        public static @Nullable String getTargetEntity​(List<? extends AnnotationMirror> annotations)
        Parameters:
        annotations - list of annotation mirrors.
        Returns:
        target entity class name as string or null if no targetEntity is here or if equals to void
      • findMappedSuperClass

        public static @Nullable String findMappedSuperClass​(Metamodel entity,
                                                            Context context)
      • implementsInterface

        public static boolean implementsInterface​(TypeElement type,
                                                  String interfaceName)
      • extendsClass

        public static boolean extendsClass​(TypeElement type,
                                           String className)
      • isPrimitive

        public static boolean isPrimitive​(String paramType)