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

java.lang.Object
  extended by org.fest.reflect.field.FieldTypeRef<T>
Type Parameters:
T - the generic type of the field.

public class FieldTypeRef<T>
extends Object

Understands the type of a field to access using Java Reflection. This implementation supports Java generics.

The following is an example of proper usage of this class:

   // Retrieves the value of the field "powers"
   List<String> powers = field("powers").ofType(new TypeRef<List<String>>() {}).in(jedi).get();

   // Sets the value of the field "powers"
   List<String> powers = new ArrayList<String>();
   powers.add("heal");
   field("powers").ofType(new TypeRef<List<String>>() {}).in(jedi).set(powers);
 

Since:
1.1
Author:
Alex Ruiz

Method Summary
 Invoker<T> in(Object target)
          Returns a new field invoker.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

in

public Invoker<T> in(Object target)
Returns a new field invoker. A field invoker is capable of accessing (read/write) the underlying field.

Parameters:
target - the object containing the field of interest.
Returns:
the created field invoker.
Throws:
NullPointerException - if the given target is null.
ReflectionError - if a field with a matching name and type cannot be found.


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