r01f.reflection.fluent
Class PropertyReflection
java.lang.Object
r01f.reflection.fluent.PropertyReflection
public final class PropertyReflection
- extends java.lang.Object
Bean Introspection
Usage example:
// Retrieves the value of the property "name"
String name = Reflection.property("name").ofType(String.class).in(person).get();
// Sets the value of the property "name" to "Yoda"
Reflection.property("name").ofType(String.class).in(person).set("Yoda");
// Retrieves the value of the property "powers"
List powers = Reflection.property("powers").ofType(new TypeRef>() {}).in(jedi).get();
// Sets the value of the property "powers"
List powers = new ArrayList();
powers.add("heal");
Reflection.property("powers").ofType(new TypeRef>() {}).in(jedi).set(powers);
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_propertyName
private final java.lang.String _propertyName
PropertyReflection
private PropertyReflection(java.lang.String name)
startPropertyAccess
static PropertyReflection startPropertyAccess(java.lang.String propertyName)
- Creates a new
PropertyReflection: the starting point of the fluent interface for accessing properties using Bean Introspection.
- Parameters:
propertyName - the name of the property to access using Bean Introspection.
- Returns:
- the created
PropertyName.
- Throws:
java.lang.NullPointerException - if the given name is null.
java.lang.IllegalArgumentException - if the given name is empty.
ofType
public <T> PropertyTypes.PropertyType<T> ofType(java.lang.Class<T> type)
- Sets the type of the property to access.
- Type Parameters:
T - the generic type of the property type.- Parameters:
type - the type of the property to access.
- Returns:
- a recipient for the property type.
- Throws:
java.lang.NullPointerException - if the given type is null.
ofType
public <T> PropertyTypes.PropertyTypeGenerics<T> ofType(TypeRef<T> type)
- Sets the type reference of the property to access.
This method reduces casting when the type of the property to access uses generics.
Usage example:
List powers = Reflection.property("powers").ofType(new TypeRef>() {}).in(jedi).get();
- Type Parameters:
T - the generic type of the property type.- Parameters:
type - the type of the property to access.
- Returns:
- a recipient for the property type.
- Throws:
java.lang.NullPointerException - if the given type reference is null.
validateIsNotNullOrEmpty
private static void validateIsNotNullOrEmpty(java.lang.String name)