@Test void set() { ClassWithStringField target = new ClassWithStringField(); String value = UUID.randomUUID().toString(); Field field = ClassUtil.getDeclaredField(ClassWithStringField.class, "stringField"); FieldUtil.set(field, target, value); assertThat(target.getStringField(), equalTo(value)); }
public static void set(Field field, Object target, Object value) { field.setAccessible(true); try { field.set(target, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
FieldUtil extends UtilityClass { public static void set(Field field, Object target, Object value) { field.setAccessible(true); try { field.set(target, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } }
FieldUtil extends UtilityClass { public static void set(Field field, Object target, Object value) { field.setAccessible(true); try { field.set(target, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }  }
FieldUtil extends UtilityClass { public static void set(Field field, Object target, Object value) { field.setAccessible(true); try { field.set(target, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }  static void set(Field field, Object target, Object value); static Object get(Field field, Object target); static Object get(String fieldName, Object target); static Optional<Class<?>> genericTypeArgument(Field field, int index); static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field); static Optional<A> annotation(Class<A> annotationClass, Field field); }
FieldUtil extends UtilityClass { public static void set(Field field, Object target, Object value) { field.setAccessible(true); try { field.set(target, value); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }  static void set(Field field, Object target, Object value); static Object get(Field field, Object target); static Object get(String fieldName, Object target); static Optional<Class<?>> genericTypeArgument(Field field, int index); static boolean hasAnnotation(Class<? extends Annotation> annotationClass, Field field); static Optional<A> annotation(Class<A> annotationClass, Field field);  }