public final class StaticFieldName extends Object
The following is an example of proper usage of this class:
// Retrieves the value of the static field "count" int count =staticField
("count").ofType
(int.class).in
(Person.class).get
(); // Sets the value of the static field "count" to 3staticField
("count").ofType
(int.class).in
(Person.class).set
(3); // 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);
Modifier and Type | Method and Description |
---|---|
static StaticFieldName |
beginStaticFieldAccess(String name)
Creates a new
: the starting point of the fluent interface for accessing
static fields using Java Reflection. |
<T> StaticFieldType<T> |
ofType(Class<T> type)
Sets the type of the field to access.
|
<T> StaticFieldTypeRef<T> |
ofType(TypeRef<T> type)
Sets the type reference of the field to access.
|
public static StaticFieldName beginStaticFieldAccess(String name)
StaticFieldName
: the starting point of the fluent interface for accessing
static fields using Java Reflection.name
- the name of the field to access using Java Reflection.StaticFieldName
.NullPointerException
- if the given name is null
.IllegalArgumentException
- if the given name is empty.public <T> StaticFieldType<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> StaticFieldTypeRef<T> ofType(TypeRef<T> type)
For example:
List<String> commmonPowers =staticField
("commonPowers").ofType
(newTypeRef
<List<String>>() {}).in
(Jedi.class).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
.Copyright © 2007-2013 FEST (Fixtures for Easy Software Testing). All Rights Reserved.