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 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