@Test public void testUpdate() throws NoSuchFieldException, ReflectException { Employee employee = new Employee(); employee.setSalary(1); employee.setAge(25); employee.weight = 65; Field field1 = Person.class.getDeclaredField("age"); Field field2 = Person.class.getDeclaredField("weight"); Field field3 = Employee.class.getDeclaredField("salary"); Reflect.set(field1, employee, 26); Reflect.set(field2, employee, 66); Reflect.set(field3, employee, 2); Assert.assertEquals(26, employee.getAge()); Assert.assertEquals(66, employee.weight, 0); Assert.assertEquals(2, employee.getSalary(), 0); }
public static void set(final Field field, final Object target, final Object value) throws ReflectException { if (field == null || target == null) { return; } FieldAccessor accessor = getAccessor(field); if (accessor != null) { accessor.set(target, value); } }
Reflect { public static void set(final Field field, final Object target, final Object value) throws ReflectException { if (field == null || target == null) { return; } FieldAccessor accessor = getAccessor(field); if (accessor != null) { accessor.set(target, value); } } }
Reflect { public static void set(final Field field, final Object target, final Object value) throws ReflectException { if (field == null || target == null) { return; } FieldAccessor accessor = getAccessor(field); if (accessor != null) { accessor.set(target, value); } }  }
Reflect { public static void set(final Field field, final Object target, final Object value) throws ReflectException { if (field == null || target == null) { return; } FieldAccessor accessor = getAccessor(field); if (accessor != null) { accessor.set(target, value); } }  static FieldAccessor getAccessor(Field field); static void set(final Field field, final Object target, final Object value); static Object get(final Field field, final Object target); static int size(final Class<?> type, final Object value); }
Reflect { public static void set(final Field field, final Object target, final Object value) throws ReflectException { if (field == null || target == null) { return; } FieldAccessor accessor = getAccessor(field); if (accessor != null) { accessor.set(target, value); } }  static FieldAccessor getAccessor(Field field); static void set(final Field field, final Object target, final Object value); static Object get(final Field field, final Object target); static int size(final Class<?> type, final Object value);  }