public static boolean setField(Object target, String name, Object value) {
        try {
            Field field = target.getClass().getDeclaredField(name);
            field.setAccessible(true);
            field.set(target, value);
            return true;
        } catch (NoSuchFieldException e) {
            return false;
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public static boolean setField(Object target, String name, Object value) {
        try {
            Field field = target.getClass().getDeclaredField(name);
            field.setAccessible(true);
            field.set(target, value);
            return true;
        } catch (NoSuchFieldException e) {
            return false;
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public static boolean setField ( Object target , String name , Object value ) { try { Field field = target . getClass ( ) . getDeclaredField ( name ) ; field . setAccessible ( true ) ; field . set ( target , value ) ; return true ; } catch ( NoSuchFieldException e ) { return false ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Set the field identified by name to the given value.
@param target
@param name
@param value
@return true on success, false if field wasn't found.
Set the field identified by name to the given value .