Package org.apache.groovy.contracts.util
Class FieldValues
java.lang.Object
org.apache.groovy.contracts.util.FieldValues
This utility is meant to be used to replace direct calls to private
field variables in class invariants.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TfieldValue(Object obj, String fieldName, Class<T> type) Reads a field value reflectively from the target object wrapped by a generated closure instance.
-
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 instancefieldName- the field name to read from the wrapped target objecttype- the expected field type- Returns:
- the reflected field value
- Throws:
IllegalAccessException- if reflective access fails
-