org.fest.reflect.field
Class Invoker<T>

java.lang.Object
  extended by org.fest.reflect.field.Invoker<T>
Type Parameters:
T - the declared type for the field to access.

public final class Invoker<T>
extends Object

Understands the use of reflection to access a field from an object.

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 static field "count"
   int count = staticField("count").ofType(int.class).in(Person.class).get();

   // Sets the value of the static field "count" to 3
   field("count").ofType(int.class).in(Person.class).set(3);
 

Author:
Alex Ruiz

Method Summary
 T get()
          Returns the value of the field managed by this class.
 Field info()
          Returns the "real" field managed by this class.
 void set(T value)
          Sets a value in the field managed by this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

set

public void set(T value)
Sets a value in the field managed by this class.

Parameters:
value - the value to set.
Throws:
ReflectionError - if the given value cannot be set.

get

public T get()
Returns the value of the field managed by this class.

Returns:
the value of the field managed by this class.
Throws:
ReflectionError - if the value of the field cannot be retrieved.

info

public Field info()
Returns the "real" field managed by this class.

Returns:
the "real" field managed by this class.


Copyright © 2007-2010 FEST (Fixtures for Easy Software Testing). All Rights Reserved.