Package org.fest.reflect.beanproperty
Class Invoker<T>
java.lang.Object
org.fest.reflect.beanproperty.Invoker<T>
- Type Parameters:
T
- the declared type for the property to access.
Understands the use of instrospection to access a property from a JavaBean.
The following is an example of proper usage of this class:
// Retrieves the value of the property "name" String name =property
("name").ofType
(String.class).in
(person).get
(); // Sets the value of the property "name" to "Yoda"property
("name").ofType
(String.class).in
(person).set
("Yoda"); // Retrieves the value of the static property "count" int count =staticField
("count").ofType
(int.class).in
(Person.class).get
(); // Sets the value of the static property "count" to 3property
("count").ofType
(int.class).in
(Person.class).set
(3);
- Since:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final PropertyDescriptor
private final String
private final Object
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Invoker
(String propertyName, Object target, PropertyDescriptor descriptor) -
Method Summary
Modifier and TypeMethodDescriptionprivate static <T> Invoker<T>
createInvoker
(String name, Class<?> expectedType, Object target) private static PropertyDescriptor
descriptorForProperty
(String propertyName, Object target) get()
Returns the value of the property managed by this class.private static ReflectionError
incorrectPropertyType
(String name, Object target, Class<?> actual, Class<?> expected) info()
Returns the "real" property managed by this class.(package private) static <T> Invoker<T>
newInvoker
(String name, Class<T> expectedType, Object target) (package private) static <T> Invoker<T>
newInvoker
(String name, TypeRef<T> expectedType, Object target) void
Sets a value in the property managed by this class.(package private) static void
verifyCorrectType
(String name, Object target, Class<?> expectedType, PropertyDescriptor descriptor)
-
Field Details
-
propertyName
-
target
-
descriptor
-
-
Constructor Details
-
Invoker
-
-
Method Details
-
newInvoker
-
newInvoker
-
createInvoker
-
descriptorForProperty
-
verifyCorrectType
static void verifyCorrectType(String name, Object target, Class<?> expectedType, PropertyDescriptor descriptor) -
incorrectPropertyType
private static ReflectionError incorrectPropertyType(String name, Object target, Class<?> actual, Class<?> expected) -
set
Sets a value in the property managed by this class.- Parameters:
value
- the value to set.- Throws:
ReflectionError
- if the given value cannot be set.
-
get
Returns the value of the property managed by this class.- Returns:
- the value of the property managed by this class.
- Throws:
ReflectionError
- if the value of the property cannot be retrieved.
-
info
Returns the "real" property managed by this class.- Returns:
- the "real" property managed by this class.
-