Class TypeUtils

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


        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.
        annotationMirror - The annotation mirror
        qualifiedName - the fully qualified class name to check against
        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.
        element - the element to check for the hosted annotation
        qualifiedName - the fully qualified class name of the annotation to check for
        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)
      • 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)
      • isPrimitive

        public static boolean isPrimitive​(String paramType)