Package org.fest.reflect.field
Class StaticFieldTypeRef<T>
java.lang.Object
org.fest.reflect.field.StaticFieldTypeRef<T>
- Type Parameters:
T- the generic type of the field.
Understands the type of a static field to access using Java Reflection.
The following is an example of proper usage of this class:
// Retrieves the value of the static field "commonPowers" List<String> commmonPowers =staticField("commonPowers").ofType(newTypeRef<List<String>>() {}).in(Jedi.class).get(); // Sets the value of the static field "commonPowers" List<String> commonPowers = new ArrayList<String>(); commonPowers.add("jump");staticField("commonPowers").ofType(newTypeRef<List<String>>() {}).in(Jedi.class).set(commonPowers);
- Since:
- 1.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a new field invoker.(package private) static <T> StaticFieldTypeRef<T>newFieldTypeRef(String name, TypeRef<T> type)
-
Field Details
-
name
-
type
-
-
Constructor Details
-
StaticFieldTypeRef
-
-
Method Details
-
newFieldTypeRef
-
in
Returns a new field invoker. A field invoker is capable of accessing (read/write) the underlying field.- Parameters:
target- the type containing the static field of interest.- Returns:
- the created field invoker.
- Throws:
NullPointerException- if the given target isnull.ReflectionError- if a static field with a matching name and type cannot be found.
-