@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("getX"); GetterInvoker invoker = FunctionalGetterInvoker.create("x", m); a.setX(Lists.newArrayList(1000000000000000L, 2l, 3L)); assertThat((String) invoker.invoke(a), is("1000000000000000,2,3")); a.setX(null); assertThat(invoker.invoke(a), nullValue()); a.setX(new ArrayList<Long>()); assertThat((String) invoker.invoke(a), is("")); }
@Nullable @Override public String apply(@Nullable List<Long> input) { if (input == null) { return null; } if (input.size() == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input.get(0)); for (int i = 1; i < input.size(); i++) { builder.append(SEPARATOR).append(input.get(i)); } return builder.toString(); }
LongListToStringFunction implements GetterFunction<List<Long>, String> { @Nullable @Override public String apply(@Nullable List<Long> input) { if (input == null) { return null; } if (input.size() == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input.get(0)); for (int i = 1; i < input.size(); i++) { builder.append(SEPARATOR).append(input.get(i)); } return builder.toString(); } }
LongListToStringFunction implements GetterFunction<List<Long>, String> { @Nullable @Override public String apply(@Nullable List<Long> input) { if (input == null) { return null; } if (input.size() == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input.get(0)); for (int i = 1; i < input.size(); i++) { builder.append(SEPARATOR).append(input.get(i)); } return builder.toString(); }  }
LongListToStringFunction implements GetterFunction<List<Long>, String> { @Nullable @Override public String apply(@Nullable List<Long> input) { if (input == null) { return null; } if (input.size() == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input.get(0)); for (int i = 1; i < input.size(); i++) { builder.append(SEPARATOR).append(input.get(i)); } return builder.toString(); }  @Nullable @Override String apply(@Nullable List<Long> input); }
LongListToStringFunction implements GetterFunction<List<Long>, String> { @Nullable @Override public String apply(@Nullable List<Long> input) { if (input == null) { return null; } if (input.size() == 0) { return ""; } StringBuilder builder = new StringBuilder(); builder.append(input.get(0)); for (int i = 1; i < input.size(); i++) { builder.append(SEPARATOR).append(input.get(i)); } return builder.toString(); }  @Nullable @Override String apply(@Nullable List<Long> input);  }