public static void writeField(final Field field, final Object target, final Object value, final boolean forceAccess)
            throws IllegalAccessException {
        Validate.isTrue(field != null, "The field must not be null");
        if (forceAccess && !field.isAccessible()) {
            field.setAccessible(true);
        } else {
            MemberUtils.setAccessibleWorkaround(field);
        }
        field.set(target, value);
    }
public static void writeField ( final Field field , final Object target , final Object value , final boolean forceAccess ) throws IllegalAccessException { Validate . isTrue ( field != null , "The field must not be null" ) ; if ( forceAccess && ! field . isAccessible ( ) ) { field . setAccessible ( true ) ; } else { MemberUtils . setAccessibleWorkaround ( field ) ; } field . set ( target , value ) ; }
Writes a {@link Field}.

@param field
to write
@param target
the object to call on, may be {@code null} for {@code static} fields
@param value
to set
@param forceAccess
whether to break scope restrictions using the
{@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} method. {@code false} will only
match {@code public} fields.
@throws IllegalArgumentException
if the field is {@code null} or {@code value} is not assignable
@throws IllegalAccessException
if the field is not made accessible or is {@code final}