r01f.reflection.fluent
Class StaticFieldTypes.StaticFieldType<T>
java.lang.Object
r01f.reflection.fluent.StaticFieldTypes.StaticFieldType<T>
- Type Parameters:
T - the generic type of the field.
Usage example:
// Retrieves the value of the static field "count"
int count = Reflection.staticField("count").ofType(int.class).in(Person.class).get();
// Sets the value of the static field "count" to 3
Reflection.staticField("count").ofType(int.class).in(Person.class).set(3);
- Enclosing class:
- StaticFieldTypes
public static class StaticFieldTypes.StaticFieldType<T>
- extends java.lang.Object
Static field to access using Java Reflection.
|
Method Summary |
FieldInvoker<T> |
in(java.lang.Class<?> target)
Returns a new field invoker. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_fieldName
private final java.lang.String _fieldName
_fieldType
private final java.lang.Class<T> _fieldType
StaticFieldTypes.StaticFieldType
StaticFieldTypes.StaticFieldType(java.lang.String fieldName,
java.lang.Class<T> fieldType)
in
public FieldInvoker<T> in(java.lang.Class<?> target)
- 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:
java.lang.NullPointerException - if the given target is null.
ReflectionError - if a static field with a matching name and type cannot be found.