@Test public void testApply() throws Exception { A a = new A(); List<Integer> list = Lists.newArrayList(1, 2, 3); a.setList(list); Method m = A.class.getDeclaredMethod("getList"); GetterInvoker invoker = FunctionalGetterInvoker.create("list", m); String r = (String) invoker.invoke(a); assertThat(r, is(new Gson().toJson(list))); B b = new B(3, 5); a.setB(b); Method m2 = A.class.getDeclaredMethod("getB"); GetterInvoker invoker2 = FunctionalGetterInvoker.create("b", m2); String r2 = (String) invoker2.invoke(a); assertThat(r2, is(new Gson().toJson(b))); }
@Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); } }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); }  }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); }  @Nullable @Override String apply(@Nullable Object input); }
ObjectToGsonFunction implements GetterFunction<Object, String> { @Nullable @Override public String apply(@Nullable Object input) { return input == null ? null : new Gson().toJson(input); }  @Nullable @Override String apply(@Nullable Object input);  }