Class TypeUtils


  • public final class TypeUtils
    extends java.lang.Object
    Utility class.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean containsAnnotation​(javax.lang.model.element.Element element, java.lang.String... annotations)  
      static void determineAccessTypeForHierarchy​(javax.lang.model.element.TypeElement searchedElement, Context context)  
      static AccessType determineAnnotationSpecifiedAccessType​(javax.lang.model.element.Element element)  
      static java.lang.String extractClosestRealTypeAsString​(javax.lang.model.type.TypeMirror type, Context context)  
      static javax.lang.model.element.AnnotationMirror getAnnotationMirror​(javax.lang.model.element.Element element, java.lang.String fqcn)
      Checks whether the Element hosts the annotation with the given fully qualified class name.
      static java.lang.Object getAnnotationValue​(javax.lang.model.element.AnnotationMirror annotationMirror, java.lang.String parameterValue)  
      static javax.lang.model.type.TypeMirror getCollectionElementType​(javax.lang.model.type.DeclaredType t, java.lang.String fqNameOfReturnedType, java.lang.String explicitTargetEntityName, Context context)  
      static javax.lang.model.element.ElementKind getElementKindForAccessType​(AccessType accessType)  
      static java.lang.String getKeyType​(javax.lang.model.type.DeclaredType t, Context context)  
      static javax.lang.model.element.TypeElement getSuperclassTypeElement​(javax.lang.model.element.TypeElement element)  
      static boolean isAnnotationMirrorOfType​(javax.lang.model.element.AnnotationMirror annotationMirror, java.lang.String fqcn)
      Returns true if the provided annotation type is of the same type as the provided class, false otherwise.
      static java.lang.String toArrayTypeString​(javax.lang.model.type.ArrayType type, Context context)  
      static java.lang.String toTypeString​(javax.lang.model.type.TypeMirror type)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_ANNOTATION_PARAMETER_NAME

        public static final java.lang.String DEFAULT_ANNOTATION_PARAMETER_NAME
        See Also:
        Constant Field Values
    • Method Detail

      • toTypeString

        public static java.lang.String toTypeString​(javax.lang.model.type.TypeMirror type)
      • toArrayTypeString

        public static java.lang.String toArrayTypeString​(javax.lang.model.type.ArrayType type,
                                                         Context context)
      • getSuperclassTypeElement

        public static javax.lang.model.element.TypeElement getSuperclassTypeElement​(javax.lang.model.element.TypeElement element)
      • extractClosestRealTypeAsString

        public static java.lang.String extractClosestRealTypeAsString​(javax.lang.model.type.TypeMirror type,
                                                                      Context context)
      • containsAnnotation

        public static boolean containsAnnotation​(javax.lang.model.element.Element element,
                                                 java.lang.String... annotations)
      • isAnnotationMirrorOfType

        public static boolean isAnnotationMirrorOfType​(javax.lang.model.element.AnnotationMirror annotationMirror,
                                                       java.lang.String fqcn)
        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
        fqcn - 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 javax.lang.model.element.AnnotationMirror getAnnotationMirror​(javax.lang.model.element.Element element,
                                                                                    java.lang.String fqcn)
        Checks whether the Element hosts the annotation with the given fully qualified class name.
        Parameters:
        element - the element to check for the hosted annotation
        fqcn - 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.
      • getAnnotationValue

        public static java.lang.Object getAnnotationValue​(javax.lang.model.element.AnnotationMirror annotationMirror,
                                                          java.lang.String parameterValue)
      • determineAccessTypeForHierarchy

        public static void determineAccessTypeForHierarchy​(javax.lang.model.element.TypeElement searchedElement,
                                                           Context context)
      • getCollectionElementType

        public static javax.lang.model.type.TypeMirror getCollectionElementType​(javax.lang.model.type.DeclaredType t,
                                                                                java.lang.String fqNameOfReturnedType,
                                                                                java.lang.String explicitTargetEntityName,
                                                                                Context context)
      • determineAnnotationSpecifiedAccessType

        public static AccessType determineAnnotationSpecifiedAccessType​(javax.lang.model.element.Element element)
      • getElementKindForAccessType

        public static javax.lang.model.element.ElementKind getElementKindForAccessType​(AccessType accessType)
      • getKeyType

        public static java.lang.String getKeyType​(javax.lang.model.type.DeclaredType t,
                                                  Context context)