com.ferri.core.utils
Class ClazzUtils

java.lang.Object
  extended by com.ferri.core.utils.ClazzUtils

public abstract class ClazzUtils
extends Object


Constructor Summary
ClazzUtils()
           
 
Method Summary
static Type getEntityType(Class<?> genericClazz, Class<?> expectedGenericParent)
          Obtain the expected type from the generic parent.
static Type getEntityType(Class<?> genericClazz, Class<?> expectedGenericParent, Integer expectedIndex)
          Obtain the expected type from the generic parent
static Type getSelectedType(Type[] types, Integer paramIndex)
          Obtain the expecte type from the given array types
When the type have duplicates an index is necesary.
static Class<?> getTopClass(Class<?> currentClazz, Class<?> expectedParent)
          Obtain the expected parent from the given class instance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClazzUtils

public ClazzUtils()
Method Detail

getEntityType

public static Type getEntityType(Class<?> genericClazz,
                                 Class<?> expectedGenericParent)
                          throws GenericClassNotFound,
                                 GenericTypeNotFound
Obtain the expected type from the generic parent.
The first type matched is returned.

Parameters:
genericClazz - the given class that inherit from a generic parent clazz.
expectedGenericParent - the generic parent class to match.
expectedType - the type to match
Returns:
the expected type from the given parameters *
Throws:
GenericClassNotFound - if the given class dont have the expected parent class
GenericTypeNotFound - if the given type is not found

getEntityType

public static Type getEntityType(Class<?> genericClazz,
                                 Class<?> expectedGenericParent,
                                 Integer expectedIndex)
                          throws GenericClassNotFound,
                                 GenericTypeNotFound
Obtain the expected type from the generic parent

Parameters:
genericClazz - the given class that inherit from a generic parent clazz.
expectedGenericParent - the generic parent class to match.
expectedType - the type to match
expectedIndex - the index of the type to match if has more than one
Returns:
the expected type from the given parameters
Throws:
GenericClassNotFound - if the given class dont have the expected parent class
GenericTypeNotFound - if the given type is not found

getSelectedType

public static Type getSelectedType(Type[] types,
                                   Integer paramIndex)
                            throws GenericTypeNotFound
Obtain the expecte type from the given array types
When the type have duplicates an index is necesary.

Parameters:
types - the allowed array type
expectedType - the type to match.
paramIndex - the index start at 1
Returns:
the type expeced from the list.
Throws:
GenericTypeNotFound - if the given type is not found

getTopClass

public static Class<?> getTopClass(Class<?> currentClazz,
                                   Class<?> expectedParent)
Obtain the expected parent from the given class instance

Parameters:
currentClazz - the given class instance
expectedParent - the parent to match
Returns:
the parent class definition.