|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.reflect.field.FieldName
public final class FieldName
Understands the name of a field to access using Java Reflection.
The following is an example of proper usage of this class:
// Retrieves the value of the field "name" String name =field("name").ofType(String.class).in(person).get(); // Sets the value of the field "name" to "Yoda"field("name").ofType(String.class).in(person).set("Yoda"); // Retrieves the value of the field "powers" List<String> powers =field("powers").ofType(newTypeRef<List<String>>() {}).in(jedi).get(); // Sets the value of the field "powers" List<String> powers = new ArrayList<String>(); powers.add("heal");field("powers").ofType(newTypeRef<List<String>>() {}).in(jedi).set(powers);
| Method Summary | ||
|---|---|---|
static FieldName |
beginFieldAccess(String name)
Creates a new : the starting point of the fluent interface for accessing fields
using Java Reflection. |
|
|
ofType(Class<T> type)
Sets the type of the field to access. |
|
|
ofType(TypeRef<T> type)
Sets the type reference of the field to access. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static FieldName beginFieldAccess(String name)
FieldName: the starting point of the fluent interface for accessing fields
using Java Reflection.
name - the name of the field to access using Java Reflection.
FieldName.
NullPointerException - if the given name is null.
IllegalArgumentException - if the given name is empty.public <T> FieldType<T> ofType(Class<T> type)
T - the generic type of the field type.type - the type of the field to access.
NullPointerException - if the given type is null.public <T> FieldTypeRef<T> ofType(TypeRef<T> type)
For example:
List<String> powers =field("powers").ofType(newTypeRef<List<String>>() {}).in(jedi).get();
T - the generic type of the field type.type - the type of the field to access.
NullPointerException - if the given type reference is null.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||