|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.datastore.reflect.ReflectionUtils
public class ReflectionUtils
Provides methods to help with reflective operations
Field Summary | |
---|---|
static Map<Class<?>,Class<?>> |
PRIMITIVE_TYPE_COMPATIBLE_CLASSES
|
Constructor Summary | |
---|---|
ReflectionUtils()
|
Method Summary | |
---|---|
static PropertyDescriptor[] |
getPropertiesOfType(Class<?> clazz,
Class<?> propertyType)
Retrieves all the properties of the given class for the given type |
static Object |
instantiate(Class clazz)
Instantiates an object catching any relevant exceptions and rethrowing as a runtime exception |
static boolean |
isAssignableFrom(Class<?> leftType,
Class<?> rightType)
Tests whether or not the left hand type is compatible with the right hand type in Groovy terms, i.e. |
static void |
makeAccessible(Field field)
Make the given field accessible, explicitly setting it accessible if necessary. |
static void |
makeAccessible(Method method)
Make the given method accessible, explicitly setting it accessible if necessary. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Map<Class<?>,Class<?>> PRIMITIVE_TYPE_COMPATIBLE_CLASSES
Constructor Detail |
---|
public ReflectionUtils()
Method Detail |
---|
public static void makeAccessible(Field field)
setAccessible(true)
method is only called when actually necessary,
to avoid unnecessary conflicts with a JVM SecurityManager (if active).
Based on the same method in Spring core.
field
- the field to make accessibleAccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
public static void makeAccessible(Method method)
setAccessible(true)
method is only called when actually necessary,
to avoid unnecessary conflicts with a JVM SecurityManager (if active).
Based on the same method in Spring core.
method
- the method to make accessibleAccessibleObject.setAccessible(java.lang.reflect.AccessibleObject[], boolean)
public static boolean isAssignableFrom(Class<?> leftType, Class<?> rightType)
Tests whether or not the left hand type is compatible with the right hand type in Groovy terms, i.e. can the left type be assigned a value of the right hand type in Groovy.
This handles Java primitive type equivalence and uses isAssignableFrom for all other types, with a bit of magic for native types and polymorphism i.e. Number assigned an int. If either parameter is null an exception is thrown
leftType
- The type of the left hand part of a notional assignmentrightType
- The type of the right hand part of a notional assignment
public static Object instantiate(Class clazz)
clazz
- The class
public static PropertyDescriptor[] getPropertiesOfType(Class<?> clazz, Class<?> propertyType)
clazz
- The class to retrieve the properties frompropertyType
- The type of the properties you wish to retrieve
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |