@Test public void testSafeSet_optionalIsEmpty() { BasicDto basic = new BasicDto(); basic.setString("oldValue"); SetterUtils.safeSet(basic::setString,Optional.empty()); assertNull(basic.getString()); }
public static <T> void safeSet(final Consumer<T> setter, final Optional<T> value) { if (value != null) { setter.accept(value.orElse(null)); } }
SetterUtils { public static <T> void safeSet(final Consumer<T> setter, final Optional<T> value) { if (value != null) { setter.accept(value.orElse(null)); } } }
SetterUtils { public static <T> void safeSet(final Consumer<T> setter, final Optional<T> value) { if (value != null) { setter.accept(value.orElse(null)); } }  }
SetterUtils { public static <T> void safeSet(final Consumer<T> setter, final Optional<T> value) { if (value != null) { setter.accept(value.orElse(null)); } }  static void safeSet(final Consumer<T> setter, final Optional<T> value); static void safeSet(final Consumer<T> setter, final Optional<T> value, final Class primitive); static void set(final Consumer<T> setter, final Optional<T> value); }
SetterUtils { public static <T> void safeSet(final Consumer<T> setter, final Optional<T> value) { if (value != null) { setter.accept(value.orElse(null)); } }  static void safeSet(final Consumer<T> setter, final Optional<T> value); static void safeSet(final Consumer<T> setter, final Optional<T> value, final Class primitive); static void set(final Consumer<T> setter, final Optional<T> value);  }