@Test void forFieldOptionalAndSetPrefixSetter() { BiConsumer<SetterTestClass,Optional<BigDecimal>> setter = Setter.forField(SetterTestClass.class, BigDecimal.class, ClassUtil.getDeclaredField(SetterTestClass.class, "optionalBigDecimal")); SetterTestClass target = mock(SetterTestClass.class); setter.accept(target, Optional.of(BigDecimal.ZERO)); verify(target).setOptionalBigDecimal(Optional.of(BigDecimal.ZERO)); verifyNoMoreInteractions(target); }
@SuppressWarnings("unchecked") public static <T, V> BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field) { return forField((Class<T>) targetClass.getRawType(), argType, field); }
Setter extends UtilityClass { @SuppressWarnings("unchecked") public static <T, V> BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field) { return forField((Class<T>) targetClass.getRawType(), argType, field); } }
Setter extends UtilityClass { @SuppressWarnings("unchecked") public static <T, V> BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field) { return forField((Class<T>) targetClass.getRawType(), argType, field); }  }
Setter extends UtilityClass { @SuppressWarnings("unchecked") public static <T, V> BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field) { return forField((Class<T>) targetClass.getRawType(), argType, field); }  @SuppressWarnings("unchecked") static BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field); static BiConsumer<T, Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field); }
Setter extends UtilityClass { @SuppressWarnings("unchecked") public static <T, V> BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field) { return forField((Class<T>) targetClass.getRawType(), argType, field); }  @SuppressWarnings("unchecked") static BiConsumer<T, Optional<V>> forField(TypeToken<T> targetClass, Class<V> argType, Field field); static BiConsumer<T, Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field);  }