public class MetadataHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
GET_PROPERTY_METHOD_PREFIX |
static java.lang.String |
IS_PROPERTY_METHOD_PREFIX |
static java.lang.String |
PERSISTENCE_PACKAGE_PREFIX |
static java.lang.String |
SET_IS_PROPERTY_METHOD_PREFIX |
static java.lang.String |
SET_PROPERTY_METHOD_PREFIX |
Constructor and Description |
---|
MetadataHelper() |
Modifier and Type | Method and Description |
---|---|
static ClassDescriptor |
findDescriptor(Project project,
java.lang.Class cls)
INTERNAL:
Search the given sessions list of ordered descriptors for a descriptor
for the class named the same as the given class.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class annotation,
java.lang.reflect.AnnotatedElement annotatedElement)
INTERNAL:
Method to read an annotation.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class annotation,
java.lang.reflect.AnnotatedElement annotatedElement,
MetadataDescriptor descriptor)
INTERNAL:
Wrapper to the getAnnotation() call to check if we should ignore
annotations.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class annotation,
MetadataAccessor accessor)
INTERNAL:
Wrapper to the getAnnotation() call using an Accessor.
|
static <T extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class annotation,
MetadataDescriptor descriptor)
INTERNAL:
Wrapper to the getAnnotation() call using an MetadataDescriptor.
|
static java.lang.String |
getAttributeNameFromMethodName(java.lang.String methodName)
INTERNAL:
Method to convert a getXyz or isXyz method name to an xyz attribute name.
|
static java.lang.reflect.Method[] |
getCandidateCallbackMethodsForDefaultListener(MetadataEntityListener listener)
INTERNAL:
Returns the same candidate methods as an entity listener would.
|
static java.lang.reflect.Method[] |
getCandidateCallbackMethodsForEntityClass(java.lang.Class entityClass)
INTERNAL:
Return only the actual methods declared on this entity class.
|
static java.lang.reflect.Method[] |
getCandidateCallbackMethodsForEntityListener(MetadataEntityListener listener)
INTERNAL:
Returns a list of methods from the given class, which can have private,
protected, package and public access, AND will also return public
methods from superclasses.
|
static java.lang.reflect.Method[] |
getCandidateCallbackMethodsForMappedSuperclass(java.lang.Class mappedSuperclass,
java.lang.Class entityClass)
INTERNAL:
Return potential lifecyle callback event methods for a mapped superclass.
|
static java.lang.Class |
getClassForName(java.lang.String classname,
java.lang.ClassLoader loader)
INTERNAL:
Load a class from a given class name.
|
static java.lang.Object |
getClassInstance(java.lang.Class cls)
INTERNAL:
Create a new instance of the class given.
|
static java.lang.Object |
getClassInstance(java.lang.String className,
java.lang.ClassLoader loader)
INTERNAL:
Create a new instance of the class name.
|
static int |
getDeclaredAnnotationsCount(java.lang.reflect.AnnotatedElement annotatedElement,
MetadataDescriptor descriptor)
INTERNAL:
|
static java.lang.reflect.Method[] |
getDeclaredMethods(java.lang.Class cls)
INTERNAL:
Get the declared methods from a class using the doPriveleged security
access.
|
static java.lang.Class |
getDiscriminatorType(java.lang.String discriminatorType)
INTERNAL:
Return the discriminator type class for the given discriminator type.
|
static java.lang.Class |
getFieldClassification(java.lang.String temporalType)
INTERNAL:
Return the field classification for the given temporal type.
|
static java.lang.reflect.Field |
getFieldForName(java.lang.String fieldName,
java.lang.Class javaClass)
INTERNAL:
Helper method that will return a given field based on the provided attribute name.
|
static java.lang.reflect.Field[] |
getFields(java.lang.Class cls)
INTERNAL:
Get the declared fields from a class using the doPriveleged security
access.
|
static java.lang.String |
getFullyQualifiedTableName(java.lang.String tableName,
java.lang.String catalog,
java.lang.String schema)
INTERNAL:
Returns a fully qualified table name based on the values passed in.
|
static java.lang.String |
getFullyQualifiedTableName(java.lang.String name,
java.lang.String defaultName,
java.lang.String catalog,
java.lang.String schema)
INTERNAL:
Returns a fully qualified table name based on the values passed in.
|
static java.lang.reflect.Type |
getGenericReturnType(java.lang.reflect.Method method)
INTERNAL:
Method to return a generic method return type.
|
static java.lang.reflect.Type |
getGenericType(java.lang.reflect.Field field)
INTERNAL:
Method to return a generic field type.
|
static java.lang.Class |
getMapKeyTypeFromGeneric(java.lang.reflect.Type type)
INTERNAL:
Helper method to return the map key type of a generic map.
|
protected static java.lang.reflect.Method |
getMethod(java.lang.String methodName,
java.lang.Class cls,
java.lang.Class[] params)
INTERNAL:
If the methodName passed in is a declared method on cls, then return
the methodName.
|
static java.lang.reflect.Method |
getMethodForName(java.lang.reflect.Method[] methods,
java.lang.String methodName)
INTERNAL:
Find the method in the list where method.getName() == methodName.
|
static java.lang.reflect.Method |
getMethodForPropertyName(java.lang.String propertyName,
java.lang.Class cls)
INTERNAL:
Method to convert an xyz property name into a getXyz or isXyz method.
|
static java.lang.reflect.Method[] |
getMethods(java.lang.Class cls)
INTERNAL:
Get the methods from a class using the doPriveleged security access.
|
static java.lang.Class |
getRawClassFromGeneric(java.lang.reflect.Type type)
INTERNAL:
Return the raw class of the generic type.
|
static java.lang.Class |
getReturnTypeFromGeneric(java.lang.reflect.Type type)
INTERNAL:
Helper method to return the type class of a ParameterizedType.
|
static java.lang.reflect.Method |
getSetMethod(java.lang.reflect.Method method,
java.lang.Class cls)
INTERNAL:
Method to convert a getMethod into a setMethod.
|
static boolean |
havePersistenceAnnotationsDefined(java.lang.reflect.AnnotatedElement[] annotatedElements)
INTERNAL:
|
static boolean |
isAnnotationNotPresent(java.lang.Class annotation,
java.lang.reflect.AnnotatedElement annotatedElement)
INTERNAL:
Indicates whether the specified annotation is actually not present on
the specified class.
|
static boolean |
isAnnotationPresent(java.lang.Class annotation,
java.lang.reflect.AnnotatedElement annotatedElement)
INTERNAL:
Indicates whether the specified annotation is present on the specified
class.
|
static boolean |
isAnnotationPresent(java.lang.Class annotation,
java.lang.reflect.AnnotatedElement annotatedElement,
MetadataDescriptor descriptor)
INTERNAL:
Indicates whether the specified annotation is present on the specified
class.
|
static boolean |
isAnnotationPresent(java.lang.Class annotation,
MetadataDescriptor descriptor)
INTERNAL:
Indicates whether the specified annotation is present on java class
for the given descriptor metadata.
|
static boolean |
isBasic(MetadataAccessibleObject annotatedAccessor,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this accessor represents a basic mapping.
|
static boolean |
isCollectionClass(java.lang.Class cls)
INTERNAL:
Method to return whether a class is a collection or not.
|
static boolean |
isEmbedded(MetadataAccessibleObject accessibleObject,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this accessor represents an aggregate mapping.
|
static boolean |
isEmbeddedId(MetadataAccessibleObject accessibleObject,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this accessor represents an aggregate mapping.
|
static boolean |
isGenericCollectionType(java.lang.reflect.Type type)
INTERNAL:
Method to return whether a collection type is a generic.
|
static boolean |
isManyToMany(MetadataAccessibleObject accessibleObject,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this field accessor represents a m-m relationship.
|
static boolean |
isManyToOne(MetadataAccessibleObject annotatedAccessor,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this accessor represents a m-1 relationship.
|
static boolean |
isMapClass(java.lang.Class cls)
INTERNAL:
Method to return whether a class is a map or not.
|
static boolean |
isOneToMany(MetadataAccessibleObject accessibleObject,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this accessor represents a 1-m relationship.
|
static boolean |
isOneToOne(MetadataAccessibleObject accessibleObject,
MetadataDescriptor descriptor)
INTERNAL:
Return true if this accessor represents a 1-1 relationship.
|
static boolean |
isPrimitiveWrapperClass(java.lang.Class cls)
INTERNAL:
Returns true is the given class is primitive wrapper type.
|
static boolean |
isSupportedCollectionClass(java.lang.Class cls)
INTERNAL:
Method to return whether a class is a supported Collection.
|
static boolean |
isValidAttributeName(java.lang.String attributeName,
java.lang.Class javaClass)
INTERNAL:
Search the class for an attribute with a name matching 'attributeName'
|
static boolean |
isValidBlobType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is a valid blob type.
|
static boolean |
isValidClobType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is a valid clob type.
|
static boolean |
isValidDateType(java.lang.Class cls)
INTERNAL:
Returns true is the given class is or extends java.util.Date.
|
static boolean |
isValidEnumeratedType(java.lang.Class cls)
INTERNAL:
Return true if the given class is a valid enum type.
|
static boolean |
isValidLobType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is a valid lob type.
|
static boolean |
isValidPersistenceMethodName(java.lang.String methodName)
INTERNAL:
|
static boolean |
isValidSerializedType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is valid for SerializedObjectMapping.
|
static boolean |
isValidTemporalType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is a valid temporal type and must be
marked temporal.
|
static boolean |
isValidTimstampVersionLockingType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is a valid timestamp locking type.
|
static boolean |
isValidVersionLockingType(java.lang.Class cls)
INTERNAL:
Returns true if the given class is a valid version locking type.
|
static boolean |
shouldIgnoreAnnotations(java.lang.Class cls,
java.util.HashMap<java.lang.Class,MetadataDescriptor> metadataDescriptors)
INTERNAL:
Indicates whether the class should ignore annotations.
|
public static final java.lang.String IS_PROPERTY_METHOD_PREFIX
public static final java.lang.String GET_PROPERTY_METHOD_PREFIX
public static final java.lang.String SET_PROPERTY_METHOD_PREFIX
public static final java.lang.String SET_IS_PROPERTY_METHOD_PREFIX
public static final java.lang.String PERSISTENCE_PACKAGE_PREFIX
public static ClassDescriptor findDescriptor(Project project, java.lang.Class cls)
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class annotation, java.lang.reflect.AnnotatedElement annotatedElement)
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class annotation, java.lang.reflect.AnnotatedElement annotatedElement, MetadataDescriptor descriptor)
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class annotation, MetadataAccessor accessor)
public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class annotation, MetadataDescriptor descriptor)
public static java.lang.String getAttributeNameFromMethodName(java.lang.String methodName)
public static java.lang.reflect.Method[] getCandidateCallbackMethodsForDefaultListener(MetadataEntityListener listener)
public static java.lang.reflect.Method[] getCandidateCallbackMethodsForEntityClass(java.lang.Class entityClass)
public static java.lang.reflect.Method[] getCandidateCallbackMethodsForEntityListener(MetadataEntityListener listener)
public static java.lang.reflect.Method[] getCandidateCallbackMethodsForMappedSuperclass(java.lang.Class mappedSuperclass, java.lang.Class entityClass)
public static java.lang.Class getClassForName(java.lang.String classname, java.lang.ClassLoader loader)
public static java.lang.Object getClassInstance(java.lang.Class cls)
public static java.lang.Object getClassInstance(java.lang.String className, java.lang.ClassLoader loader)
public static int getDeclaredAnnotationsCount(java.lang.reflect.AnnotatedElement annotatedElement, MetadataDescriptor descriptor)
public static java.lang.reflect.Method[] getDeclaredMethods(java.lang.Class cls)
public static java.lang.Class getDiscriminatorType(java.lang.String discriminatorType)
public static java.lang.Class getFieldClassification(java.lang.String temporalType)
public static java.lang.reflect.Field getFieldForName(java.lang.String fieldName, java.lang.Class javaClass)
public static java.lang.reflect.Field[] getFields(java.lang.Class cls)
public static java.lang.String getFullyQualifiedTableName(java.lang.String tableName, java.lang.String catalog, java.lang.String schema)
public static java.lang.String getFullyQualifiedTableName(java.lang.String name, java.lang.String defaultName, java.lang.String catalog, java.lang.String schema)
public static java.lang.reflect.Type getGenericReturnType(java.lang.reflect.Method method)
public static java.lang.reflect.Type getGenericType(java.lang.reflect.Field field)
public static java.lang.Class getMapKeyTypeFromGeneric(java.lang.reflect.Type type)
protected static java.lang.reflect.Method getMethod(java.lang.String methodName, java.lang.Class cls, java.lang.Class[] params)
public static java.lang.reflect.Method getMethodForName(java.lang.reflect.Method[] methods, java.lang.String methodName)
public static java.lang.reflect.Method getMethodForPropertyName(java.lang.String propertyName, java.lang.Class cls)
public static java.lang.reflect.Method[] getMethods(java.lang.Class cls)
public static java.lang.Class getRawClassFromGeneric(java.lang.reflect.Type type)
public static java.lang.Class getReturnTypeFromGeneric(java.lang.reflect.Type type)
public static java.lang.reflect.Method getSetMethod(java.lang.reflect.Method method, java.lang.Class cls)
public static boolean havePersistenceAnnotationsDefined(java.lang.reflect.AnnotatedElement[] annotatedElements)
public static boolean isAnnotationNotPresent(java.lang.Class annotation, java.lang.reflect.AnnotatedElement annotatedElement)
public static boolean isAnnotationPresent(java.lang.Class annotation, java.lang.reflect.AnnotatedElement annotatedElement)
public static boolean isAnnotationPresent(java.lang.Class annotation, java.lang.reflect.AnnotatedElement annotatedElement, MetadataDescriptor descriptor)
public static boolean isAnnotationPresent(java.lang.Class annotation, MetadataDescriptor descriptor)
public static boolean isBasic(MetadataAccessibleObject annotatedAccessor, MetadataDescriptor descriptor)
public static boolean isCollectionClass(java.lang.Class cls)
public static boolean isEmbedded(MetadataAccessibleObject accessibleObject, MetadataDescriptor descriptor)
public static boolean isEmbeddedId(MetadataAccessibleObject accessibleObject, MetadataDescriptor descriptor)
public static boolean isGenericCollectionType(java.lang.reflect.Type type)
public static boolean isManyToMany(MetadataAccessibleObject accessibleObject, MetadataDescriptor descriptor)
public static boolean isManyToOne(MetadataAccessibleObject annotatedAccessor, MetadataDescriptor descriptor)
public static boolean isMapClass(java.lang.Class cls)
public static boolean isOneToMany(MetadataAccessibleObject accessibleObject, MetadataDescriptor descriptor)
public static boolean isOneToOne(MetadataAccessibleObject accessibleObject, MetadataDescriptor descriptor)
public static boolean isPrimitiveWrapperClass(java.lang.Class cls)
public static boolean isSupportedCollectionClass(java.lang.Class cls)
public static boolean isValidAttributeName(java.lang.String attributeName, java.lang.Class javaClass)
public static boolean isValidBlobType(java.lang.Class cls)
public static boolean isValidClobType(java.lang.Class cls)
public static boolean isValidDateType(java.lang.Class cls)
public static boolean isValidEnumeratedType(java.lang.Class cls)
public static boolean isValidLobType(java.lang.Class cls)
public static boolean isValidPersistenceMethodName(java.lang.String methodName)
public static boolean isValidSerializedType(java.lang.Class cls)
public static boolean isValidTemporalType(java.lang.Class cls)
public static boolean isValidTimstampVersionLockingType(java.lang.Class cls)
public static boolean isValidVersionLockingType(java.lang.Class cls)
public static boolean shouldIgnoreAnnotations(java.lang.Class cls, java.util.HashMap<java.lang.Class,MetadataDescriptor> metadataDescriptors)