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