public class ReflectionUtils extends Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static List<Class<?>> |
filterSameParameterizedTypes(List<Class<?>> types,
Type type)
Filters a list of types to keep only elements having the same parameterized types as the given type.
|
static <T> List<Field> |
getDeclaredFields(T type)
Get declared fields of a given type.
|
static List<Field> |
getInheritedFields(Class<?> type)
Get inherited fields of a given type.
|
static <T> List<Class<?>> |
getPublicConcreteSubTypesOf(Class<T> type)
Searches the classpath for all public concrete subtypes of the given interface or abstract class.
|
static <T> boolean |
isAbstract(Class<T> type)
Check if the type is abstract (either an interface or an abstract class).
|
static boolean |
isArrayType(Class<?> type)
Check if a type is an array type.
|
static boolean |
isCollectionType(Class<?> type)
Check if a type is a collection type.
|
static boolean |
isCollectionType(Type type)
Check if a type is a collection type.
|
static boolean |
isEnumType(Class<?> type)
Check if a type is an enum type.
|
static boolean |
isInterface(Class<?> type)
Check if a type is an interface.
|
static boolean |
isIntrospectable(Class<?> type)
Check if a type should be introspected for internal fields.
|
static boolean |
isJdkBuiltIn(Class<?> type)
Check if a type is a JDK built-in collection/map.
|
static boolean |
isMapType(Class<?> type)
Check if a type is a map type.
|
static boolean |
isParameterizedType(Type type)
Check if a type is a parameterized type
|
static boolean |
isPopulatable(Type type)
Check if a type is populatable.
|
static <T> boolean |
isPublic(Class<T> type)
Check if the type is public.
|
static boolean |
isStatic(Field field)
Check if a field is static.
|
static boolean |
isWildcardType(Type type)
Check if a type is a wildcard type
|
static void |
setProperty(Object object,
Field field,
Object value)
Set a value (accessible or not accessible) in a field of a target object.
|
public static <T> List<Field> getDeclaredFields(T type)
type
- the type to introspectpublic static List<Field> getInheritedFields(Class<?> type)
type
- the type to introspectpublic static void setProperty(Object object, Field field, Object value) throws IllegalAccessException
object
- instance to set the property onfield
- field to set the property onvalue
- value to setIllegalAccessException
- if the property cannot be setpublic static boolean isStatic(Field field)
field
- the field to checkpublic static boolean isInterface(Class<?> type)
type
- the type to checkpublic static <T> boolean isAbstract(Class<T> type)
type
- the type to checkpublic static <T> boolean isPublic(Class<T> type)
type
- the type to checkpublic static boolean isArrayType(Class<?> type)
type
- the type to check.public static boolean isEnumType(Class<?> type)
type
- the type to check.public static boolean isCollectionType(Class<?> type)
type
- the type to check.public static boolean isCollectionType(Type type)
type
- the type to check.public static boolean isPopulatable(Type type)
type
- the type to checkpublic static boolean isIntrospectable(Class<?> type)
type
- the type to checkpublic static boolean isMapType(Class<?> type)
type
- the type to checkpublic static boolean isJdkBuiltIn(Class<?> type)
type
- the type to checkpublic static boolean isParameterizedType(Type type)
type
- the type to checkpublic static boolean isWildcardType(Type type)
type
- the type to checkpublic static <T> List<Class<?>> getPublicConcreteSubTypesOf(Class<T> type)
type
- to search concrete subtypes ofpublic static List<Class<?>> filterSameParameterizedTypes(List<Class<?>> types, Type type)
type
- the type to use for the searchtypes
- a list of types to filterCopyright © 2016. All Rights Reserved.