Package: org.apache.groovy.contracts.util

## [Java] Class FieldValues

- org.apache.groovy.contracts.util.FieldValues

-     public class FieldValues
      extends Object

  This utility is meant to be used to replace direct calls to private field variables in class invariants.

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `<T>` | `public static T` | `fieldValue(Object obj, String fieldName, Class<T> type)` Reads a field value reflectively from the target object wrapped by a generated closure instance.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### <T> @GroovyABI(since = "4.0.0")
      public static T fieldValue(Object obj, String fieldName, Class<T> type)

      Reads a field value reflectively from the target object wrapped by a generated closure instance.

      throws:
        IllegalAccessException if reflective access fails
      Parameters:
        `obj` - the generated closure instance
        `fieldName` - the field name to read from the wrapped target object
        `type` - the expected field type
      Type Parameters:
        `T` - the result type
      Returns:
        the reflected field value