public final class MetadataReflectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Set<Class<? extends T>> |
getAllChildClassesForClass(Class<T> superType,
String packageDefinition,
boolean withAbstractClasses)
It will search for all classes which inherit from provided super type.
|
static Class<?> |
getClassForName(String className)
It returns raw class, under the hood is used apache lang3.
|
static Field |
getField(Class<?> targetClass,
String fieldName)
Returns lang.reflect.Field for given target class and fieldName.
|
static Field |
getField(Object targetObject,
String fieldName)
Returns lang.reflect.Field for given target object and fieldName.
|
static Method |
getMethod(Class<?> targetClass,
String methodName,
Class<?>... argClasses)
It returns method for given target object.
|
static Method |
getMethod(Object targetObject,
String methodName,
Class<?>... argClasses)
It returns method for given target object.
|
static List<Type> |
getParametrizedRawTypes(Class<?> someClass)
It returns some parametrized types for given class.
|
static Class<?> |
getParametrizedType(Class<?> originalClass,
int index)
It returns a type of generic class by given index.
|
static Class<?> |
getParametrizedType(Field field,
int index)
It returns a type of generic field by given index.
|
static Class<?> |
getParametrizedType(Object targetObject,
int index)
It returns a type of generic object by given index.
|
static TypeMetadata |
getTypeMetadataFromClass(Class<?> someClass)
It builds metadata for provided class.
|
static TypeMetadata |
getTypeMetadataFromField(Field field)
It build metadata from provided field but field needs to have all generic types as real classes.
|
static TypeMetadata |
getTypeMetadataFromField(Field field,
int index)
It returns generic type from certain field by index.
|
static TypeMetadata |
getTypeMetadataFromType(Type type)
It build metadata from simple type.
|
static TypeMetadata |
getTypeMetadataOfArray(Field field)
It returns metadata of type stored in field which is array type.
|
static Class<?> |
getTypeOfArrayField(Field field)
Return type of field which is expected to be array field.
|
static boolean |
isArrayType(Class<?> someClass)
It checks that given class is array type.
|
static boolean |
isArrayType(Field field)
It checks that given field is array type.
|
static boolean |
isCollectionType(Class<?> someClass)
It checks that given class is collection type.
|
static boolean |
isCollectionType(Field field)
It checks that given field is collection type.
|
static boolean |
isEnumType(Class<?> someClass)
It checks that given class is simple enum type.
|
static boolean |
isEnumType(Field field)
It checks that given field is simple enum type.
|
static boolean |
isHavingElementsType(Class<?> someClass)
It checks that given class is array or collection type.
|
static boolean |
isHavingElementsType(Field field)
It checks that given field is array or collection type.
|
static boolean |
isMapType(Class<?> someClass)
It checks that given class is map type.
|
static boolean |
isMapType(Field field)
It checks that given field is map type.
|
static boolean |
isNumberType(Class<?> someClass)
It checks that given class is number type.
|
static boolean |
isNumberType(Field field)
It checks that given field is number type.
|
static boolean |
isSimpleType(Class<?> someClass)
It checks that given class is simple type.
|
static boolean |
isSimpleType(Field field)
It checks that given field is simple type.
|
static boolean |
isTextType(Class<?> someClass)
It checks that given class is simple string type.
|
static boolean |
isTextType(Field field)
It checks that given field is simple string type.
|
public static Field getField(Object targetObject, String fieldName)
targetObject - object from which we will start searching.fieldName - name of object property.public static Field getField(Class<?> targetClass, String fieldName)
targetClass - class from which will start searching.fieldName - name of object property.public static Class<?> getTypeOfArrayField(Field field)
field - instance of field.public static Method getMethod(Object targetObject, String methodName, Class<?>... argClasses)
targetObject - instance for which will start looking for method in object hierarchy.methodName - method name.argClasses - types of arguments.public static Method getMethod(Class<?> targetClass, String methodName, Class<?>... argClasses)
targetClass - target class for which will start looking for method in object hierarchy.methodName - method name.argClasses - types of arguments.public static <T> Set<Class<? extends T>> getAllChildClassesForClass(Class<T> superType, String packageDefinition, boolean withAbstractClasses)
T - generic type of super type of class.superType - super type which will not added to result set.packageDefinition - package from which will search for child classes.withAbstractClasses - by this flag depends that result set will have abstract classes in result set.public static boolean isSimpleType(Field field)
SIMPLE_CLASSESfield - field which will be verified.public static boolean isSimpleType(Class<?> someClass)
SIMPLE_CLASSESsomeClass - class which will be verified.public static boolean isNumberType(Field field)
SIMPLE_NUMBERSfield - field which will be verified.public static boolean isNumberType(Class<?> someClass)
SIMPLE_NUMBERSsomeClass - class which will be verified.public static boolean isTextType(Field field)
field - field which will be verified.public static boolean isTextType(Class<?> someClass)
someClass - class which will be verified.public static boolean isEnumType(Field field)
field - field which will be verified.public static boolean isEnumType(Class<?> someClass)
someClass - class which will be verified.public static boolean isMapType(Field field)
field - field which will be verified.public static boolean isMapType(Class<?> someClass)
someClass - class which will be verified.public static boolean isCollectionType(Field field)
field - field which will be verified.public static boolean isCollectionType(Class<?> someClass)
someClass - class which will be verified.public static boolean isHavingElementsType(Field field)
field - field which will be verified.public static boolean isHavingElementsType(Class<?> someClass)
someClass - class which will be verified.public static boolean isArrayType(Field field)
field - field which will be verified.public static boolean isArrayType(Class<?> someClass)
someClass - class which will be verified.public static Class<?> getParametrizedType(Field field, int index)
field - field for which will be returned class for generic type.index - of wanted generic typepublic static Class<?> getParametrizedType(Object targetObject, int index)
targetObject - instance object for which will be returned class for generic type.index - of wanted generic typepublic static Class<?> getParametrizedType(Class<?> originalClass, int index)
originalClass - class for which will be returned class for generic type.index - of wanted generic typepublic static Class<?> getClassForName(String className)
className - name of classpublic static List<Type> getParametrizedRawTypes(Class<?> someClass)
someClass - instance of certain classpublic static TypeMetadata getTypeMetadataFromClass(Class<?> someClass)
someClass - instance of class which has provided all generic types as real classpublic static TypeMetadata getTypeMetadataFromField(Field field)
field - field with all generic types as real classes.public static TypeMetadata getTypeMetadataFromField(Field field, int index)
field - for which should be resolved instance of type metadata under provided index.index - index of generic type in field.public static TypeMetadata getTypeMetadataFromType(Type type)
type - type with real class name for generic types.public static TypeMetadata getTypeMetadataOfArray(Field field)
field - array fieldCopyright © 2020. All rights reserved.