@SuppressWarnings("ResultOfMethodCallIgnored") @Test void forFieldWithGetPrefixedGetter() { Function<GetterTestClass,Optional<Short>> fieldWithNoGetter = Getter.forField(GetterTestClass.class, Short.TYPE, getDeclaredField(GetterTestClass.class, "fieldWithGetPrefixedGetter")); GetterTestClass mock = mock(GetterTestClass.class); when(mock.getFieldWithGetPrefixedGetter()).thenReturn((short) 31415); Optional<Short> result = fieldWithNoGetter.apply(mock); assertThat(result, is(Optional.of((short) 31415))); verify(mock).getFieldWithGetPrefixedGetter(); verifyNoMoreInteractions(mock); }
@NotNull public static <T, V> Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field) { return forField(TypeToken.of(targetClass), argType, field); }
Getter extends UtilityClass { @NotNull public static <T, V> Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field) { return forField(TypeToken.of(targetClass), argType, field); } }
Getter extends UtilityClass { @NotNull public static <T, V> Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field) { return forField(TypeToken.of(targetClass), argType, field); }  }
Getter extends UtilityClass { @NotNull public static <T, V> Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field) { return forField(TypeToken.of(targetClass), argType, field); }  @NotNull static Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field); @NotNull static FunctionOptional1<T,V> forField(TypeToken<T> targetType, Class<V> argType, Field field); static boolean isGetter(Method method, Field forField); static Stream<String> possibleFieldNames(String name); }
Getter extends UtilityClass { @NotNull public static <T, V> Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field) { return forField(TypeToken.of(targetClass), argType, field); }  @NotNull static Function<T,Optional<V>> forField(Class<T> targetClass, Class<V> argType, Field field); @NotNull static FunctionOptional1<T,V> forField(TypeToken<T> targetType, Class<V> argType, Field field); static boolean isGetter(Method method, Field forField); static Stream<String> possibleFieldNames(String name);  }