public final class ReflectionUtils extends Object
Modifier and Type | Method and Description |
---|---|
static Object |
convertToArray(Class type,
List<?> values) |
static <T> T |
getAnnotation(Class c,
Class<T> annClass) |
static <T> List<T> |
getAnnotations(Class c,
Class<T> annClass)
Returns the (first) instance of the annotation, on the class (or any superclass, or interfaces implemented).
|
static Class<?> |
getClass(Type type)
Get the underlying class for a type, or null if the type is a variable type.
|
static Embedded |
getClassEmbeddedAnnotation(Class c) |
static Entity |
getClassEntityAnnotation(Class c) |
static Set<Class<?>> |
getClasses(ClassLoader loader,
String packageName) |
static Set<Class<?>> |
getClasses(String packageName) |
static Field[] |
getDeclaredAndInheritedFields(Class type,
boolean returnFinalFields)
Get an array of all fields declared in the supplied class, and all its superclasses (except java.lang.Object).
|
static List<Method> |
getDeclaredAndInheritedMethods(Class type)
Get a list of all methods declared in the supplied class, and all its superclasses (except java.lang.Object), recursively.
|
static Set<Class<?>> |
getFromDirectory(ClassLoader loader,
File directory,
String packageName) |
static Set<Class<?>> |
getFromJARFile(ClassLoader loader,
String jar,
String packageName) |
static Class |
getParameterizedClass(Class c) |
static Class |
getParameterizedClass(Class c,
int index) |
static Class |
getParameterizedClass(Field field)
Get the (first) class that parameterizes the Field supplied.
|
static Class |
getParameterizedClass(Field field,
int index)
Get the class that parameterizes the Field supplied, at the index supplied (field can be parameterized with multiple param classes).
|
static Type |
getParameterizedType(Field field,
int index) |
static <T> Class<?> |
getTypeArgument(Class<? extends T> clazz,
TypeVariable<? extends GenericDeclaration> tv) |
static Class |
getTypeArgumentOfParameterizedClass(Field field,
int index,
int typeIndex)
Deprecated.
this class is unused in morphia and will be removed in a future release
|
static <T> List<Class<?>> |
getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
Deprecated.
this class is unused in morphia and will be removed in a future release
|
static List<Field> |
getValidFields(Field[] fields,
boolean returnFinalFields) |
static boolean |
implementsInterface(Class<?> type,
Class<?> interfaceClass)
Check if a class implements a specific interface.
|
static boolean |
isFieldParameterizedWithClass(Field field,
Class c)
Deprecated.
this class is unused in morphia and will be removed in a future release
|
static boolean |
isFieldParameterizedWithPropertyType(Field field)
Deprecated.
this class is unused in morphia and will be removed in a future release
|
static boolean |
isIntegerType(Class type)
Checks if the class is an integer type, i.e., is numeric but not a floating point type.
|
static boolean |
isPrimitiveLike(Class type) |
static boolean |
isPropertyType(Class type) |
static boolean |
isPropertyType(Type type)
Check if the class supplied represents a valid property type.
|
static <T> List<T> |
iterToList(Iterable<T> it) |
public static Field[] getDeclaredAndInheritedFields(Class type, boolean returnFinalFields)
type
- the class for which we want to retrieve the FieldsreturnFinalFields
- specifies whether to return final fieldspublic static List<Method> getDeclaredAndInheritedMethods(Class type)
type
- the class for which we want to retrieve the Methodspublic static boolean implementsInterface(Class<?> type, Class<?> interfaceClass)
type
- the class we want to checkinterfaceClass
- the interface class we want to check againstpublic static boolean isIntegerType(Class type)
type
- the class we want to checkpublic static boolean isPropertyType(Type type)
type
- the class we want to checkpublic static boolean isPropertyType(Class type)
public static boolean isPrimitiveLike(Class type)
public static Class getParameterizedClass(Field field)
field
- the fieldpublic static Class getParameterizedClass(Field field, int index)
field
- the fieldindex
- the index of the parameterizing classpublic static Class getTypeArgumentOfParameterizedClass(Field field, int index, int typeIndex)
public static boolean isFieldParameterizedWithClass(Field field, Class c)
field
- the fieldc
- the class to check againstpublic static boolean isFieldParameterizedWithPropertyType(Field field)
field
- the fieldpublic static <T> List<T> getAnnotations(Class c, Class<T> annClass)
public static Set<Class<?>> getFromDirectory(ClassLoader loader, File directory, String packageName) throws ClassNotFoundException
ClassNotFoundException
public static Set<Class<?>> getFromJARFile(ClassLoader loader, String jar, String packageName) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static Set<Class<?>> getClasses(String packageName) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static Set<Class<?>> getClasses(ClassLoader loader, String packageName) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
public static Class<?> getClass(Type type)
type
- the typepublic static <T> List<Class<?>> getTypeArguments(Class<T> baseClass, Class<? extends T> childClass)
baseClass
- the base classchildClass
- the child classpublic static <T> Class<?> getTypeArgument(Class<? extends T> clazz, TypeVariable<? extends GenericDeclaration> tv)
Copyright © 2016. All rights reserved.