Added by Alex Ruiz, last edited by Alex Ruiz on Mar 06, 2009  (view change)

Labels:

fest fest Delete
reflection reflection Delete
static-field static-field Delete
Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.

Accessing Static Fields

We will use an example to better understand FEST-Reflect's fluent interface for static field access.

Let's assume we have a simple class Person that defines the following field:

class Person {

   private static int count;

}

The following sections illustrate static field access using FEST-Reflect. We are going to assume the following static import:

import static org.fest.reflect.core.Reflection.staticField;

Reading the value of a static field

int count = staticField("count").ofType(int. class)
                                .in(Person.class)
                                .get();

Setting the value of a field

staticField("count").ofType(int.class)
                    .in(Person.class)
                    .set(8);

See Also