/** * Set the value in the field with the specified name in the specified object. Supports * inheritance. * * @param object The object to set the value in. * @param fieldName The name of the field. * @param value The value to set in the field. */ public static void setFieldValue( final Object object, final String fieldName, final Object value) { Validate.notNull(object, "The object to set the value in can not be null"); Validate.notEmpty(fieldName, "The name of the field can not be empty"); final Field field = getField(object, fieldName); setValue(object, value, field); }
/** * Gets the value of the field with the specified name in the specified object. Supports * inheritance. * * @param object The object to get the value from. * @param fieldClass The class of the field. * @param fieldName The name of the field. * @param <T> The class of the field. * @return The value in the field of the object. */ public static <T> T getFieldValue( final Object object, final Class<T> fieldClass, final String fieldName) { Validate.notNull(object, "The object to get the value from can not be null"); Validate.notNull(fieldClass, "The class of the field can not be null"); Validate.notEmpty(fieldName, "The name of the field can not be empty"); final Field field = getField(object, fieldName); return getValue(object, fieldClass, field); }