@Test public void setIntFieldTest() throws IOException { ClassUtil.setFieldValue(testObject, "intField", "124"); assertEquals(124, testObject.intField); }
public static void setFieldValue(Object obj, String fieldName, String value) throws IOException { Method setter = getSetter(obj, fieldName); Class<?> c = setter.getParameterTypes()[0]; Object objValue = stringToObject(fieldName, c, value); invokeSetter(setter, obj, fieldName, objValue); }
ClassUtil { public static void setFieldValue(Object obj, String fieldName, String value) throws IOException { Method setter = getSetter(obj, fieldName); Class<?> c = setter.getParameterTypes()[0]; Object objValue = stringToObject(fieldName, c, value); invokeSetter(setter, obj, fieldName, objValue); } }
ClassUtil { public static void setFieldValue(Object obj, String fieldName, String value) throws IOException { Method setter = getSetter(obj, fieldName); Class<?> c = setter.getParameterTypes()[0]; Object objValue = stringToObject(fieldName, c, value); invokeSetter(setter, obj, fieldName, objValue); } private  ClassUtil(); }
ClassUtil { public static void setFieldValue(Object obj, String fieldName, String value) throws IOException { Method setter = getSetter(obj, fieldName); Class<?> c = setter.getParameterTypes()[0]; Object objValue = stringToObject(fieldName, c, value); invokeSetter(setter, obj, fieldName, objValue); } private  ClassUtil(); static void remarkTransientFields(Class<?> targetClass); static void setFieldValue(Object obj, String fieldName, String value); static void setFieldValue(Object obj, String fieldName, Object value); static Object getFieldValue(Object obj, String field); }
ClassUtil { public static void setFieldValue(Object obj, String fieldName, String value) throws IOException { Method setter = getSetter(obj, fieldName); Class<?> c = setter.getParameterTypes()[0]; Object objValue = stringToObject(fieldName, c, value); invokeSetter(setter, obj, fieldName, objValue); } private  ClassUtil(); static void remarkTransientFields(Class<?> targetClass); static void setFieldValue(Object obj, String fieldName, String value); static void setFieldValue(Object obj, String fieldName, Object value); static Object getFieldValue(Object obj, String field);  }