|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.util.ReflectTools
public class ReflectTools
An util class with helpers for reflection operations. Used internally by Vaadin and should not be used by application developers. Subject to change at any time.
Constructor Summary | |
---|---|
ReflectTools()
|
Method Summary | |
---|---|
static java.lang.reflect.Method |
findMethod(java.lang.Class<?> cls,
java.lang.String methodName,
java.lang.Class<?>... parameterTypes)
Locates the method in the given class. |
static java.lang.Object |
getJavaFieldValue(java.lang.Object object,
java.lang.reflect.Field field)
Returns the value of the java field. |
static java.lang.Object |
getJavaFieldValue(java.lang.Object object,
java.lang.reflect.Field field,
java.lang.Class<?> propertyType)
Returns the value of the java field that is assignable to the property type. |
static void |
setJavaFieldValue(java.lang.Object object,
java.lang.reflect.Field field,
java.lang.Object value)
Sets the value of a java field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ReflectTools()
Method Detail |
---|
public static java.lang.reflect.Method findMethod(java.lang.Class<?> cls, java.lang.String methodName, java.lang.Class<?>... parameterTypes) throws java.lang.ExceptionInInitializerError
cls
- Class that contains the methodmethodName
- The name of the methodparameterTypes
- The parameter types for the method.
java.lang.ExceptionInInitializerError
- Wraps any exception in an ExceptionInInitializerError
so this method can be called from a static initializer.public static java.lang.Object getJavaFieldValue(java.lang.Object object, java.lang.reflect.Field field) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Uses getter if present, otherwise tries to access even private fields directly.
object
- The object containing the fieldfield
- The field we want to get the value for
java.lang.reflect.InvocationTargetException
- If the value could not be retrieved
java.lang.IllegalAccessException
- If the value could not be retrieved
java.lang.IllegalArgumentException
- If the value could not be retrievedpublic static java.lang.Object getJavaFieldValue(java.lang.Object object, java.lang.reflect.Field field, java.lang.Class<?> propertyType) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Uses getter if a getter for the correct return type is present, otherwise tries to access even private fields directly. If the java field is not assignable to the property type throws an IllegalArgumentException.
object
- The object containing the fieldfield
- The field we want to get the value forpropertyType
- The type the field must be assignable to
java.lang.reflect.InvocationTargetException
- If the value could not be retrieved
java.lang.IllegalAccessException
- If the value could not be retrieved
java.lang.IllegalArgumentException
- If the value could not be retrievedpublic static void setJavaFieldValue(java.lang.Object object, java.lang.reflect.Field field, java.lang.Object value) throws java.lang.IllegalAccessException, java.lang.IllegalArgumentException, java.lang.reflect.InvocationTargetException
Uses setter if present, otherwise tries to access even private fields directly.
object
- The object containing the fieldfield
- The field we want to set the value forvalue
- The value to set
java.lang.IllegalAccessException
- If the value could not be assigned to the field
java.lang.IllegalArgumentException
- If the value could not be assigned to the field
java.lang.reflect.InvocationTargetException
- If the value could not be assigned to the field
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |