Package org.apache.groovy.contracts.util

# Class FieldValues

java.lang.Object
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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FieldValues()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static <T> T`
  `fieldValue(Object obj, String fieldName, Class<T> type)`
  Reads a field value reflectively from the target object wrapped by a generated closure instance.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### FieldValues

    public FieldValues()

- ## Method Details

  - ### fieldValue

    public static <T> T fieldValue(Object obj, String fieldName, Class<T> type) throws IllegalAccessException
    Reads a field value reflectively from the target object wrapped by a generated closure instance.
    Type Parameters:
      `T` - the result type
    Parameters:
      `obj` - the generated closure instance
      `fieldName` - the field name to read from the wrapped target object
      `type` - the expected field type
    Returns:
      the reflected field value
    Throws:
      `IllegalAccessException` - if reflective access fails