org.hibernate.jpamodelgen.util
Class TypeUtils

java.lang.Object
  extended by org.hibernate.jpamodelgen.util.TypeUtils

public final class TypeUtils
extends java.lang.Object

Utility class.

Author:
Max Andersen, Hardy Ferentschik, Emmanuel Bernard

Field Summary
static java.lang.String DEFAULT_ANNOTATION_PARAMETER_NAME
           
 
Method Summary
static boolean containsAnnotation(javax.lang.model.element.Element element, java.lang.Class<?>... annotations)
           
static void determineAccessTypeForHierarchy(javax.lang.model.element.TypeElement searchedElement, Context context)
           
static javax.persistence.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.Class<? extends java.lang.annotation.Annotation> clazz)
          Checks whether the Element hosts an annotation of the specified class.
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(javax.persistence.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.Class<? extends java.lang.annotation.Annotation> clazz)
          Returns true if the provided annotation type is of the same type as the provided class, false otherwise.
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 boolean isTypeElementOfType(javax.lang.model.element.TypeElement element, java.lang.Class<?> clazz)
           
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)

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.Class<?>... annotations)

isAnnotationMirrorOfType

public static boolean isAnnotationMirrorOfType(javax.lang.model.element.AnnotationMirror annotationMirror,
                                               java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
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 http://www.retep.org/2009/02/getting-class-values-from-annotations.html.

Parameters:
annotationMirror - The annotation mirror
clazz - the class name to check against
Returns:
true if the provided annotation type is of the same type as the provided class, false otherwise.

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 http://www.retep.org/2009/02/getting-class-values-from-annotations.html.

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.

isTypeElementOfType

public static boolean isTypeElementOfType(javax.lang.model.element.TypeElement element,
                                          java.lang.Class<?> clazz)

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.

getAnnotationMirror

public static javax.lang.model.element.AnnotationMirror getAnnotationMirror(javax.lang.model.element.Element element,
                                                                            java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Checks whether the Element hosts an annotation of the specified class.

Parameters:
element - the element to check for the hosted annotation
clazz - the annotation class 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 javax.persistence.AccessType determineAnnotationSpecifiedAccessType(javax.lang.model.element.Element element)

getElementKindForAccessType

public static javax.lang.model.element.ElementKind getElementKindForAccessType(javax.persistence.AccessType accessType)

getKeyType

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


Copyright © 2009-2010. All Rights Reserved.