Class FieldType<T>

  • Type Parameters:
    T - the generic type of the field.

    public class FieldType<T>
    extends java.lang.Object
    Understands the type of a field to access using Java Reflection.

    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");
     

    Author:
    Alex Ruiz, Ivan Hristov
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Invoker<T> in​(java.lang.Object target)
      Returns a new field access invoker, capable of accessing (read/write) the underlying field.
      • 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​(java.lang.Object target)
        Returns a new field access invoker, capable of accessing (read/write) the underlying field.
        Parameters:
        target - the object containing the field of interest.
        Returns:
        the created field access invoker.
        Throws:
        java.lang.NullPointerException - if the given target is null.
        ReflectionError - if a field with a matching name and type cannot be found.