@Test public void testApply() throws Exception { A a = new A(); Method m = A.class.getDeclaredMethod("setX", long[].class); SetterInvoker invoker = FunctionalSetterInvoker.create("x", m); invoker.invoke(a, "1000000000000000000,2,3"); assertThat(Arrays.toString(a.getX()), is(Arrays.toString(new long[]{1000000000000000000L, 2, 3}))); invoker.invoke(a, null); assertThat(a.getX(), nullValue()); invoker.invoke(a, ""); assertThat(Arrays.toString(a.getX()), is(Arrays.toString(new long[]{}))); }
@Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length; i++) { r[i] = Long.parseLong(ss[i]); } return r; }
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length; i++) { r[i] = Long.parseLong(ss[i]); } return r; } }
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length; i++) { r[i] = Long.parseLong(ss[i]); } return r; }  }
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length; i++) { r[i] = Long.parseLong(ss[i]); } return r; }  @Nullable @Override long[] apply(@Nullable String input); }
StringToLongArrayFunction implements SetterFunction<String, long[]> { @Nullable @Override public long[] apply(@Nullable String input) { if (input == null) { return null; } if (input.length() == 0) { return new long[0]; } String[] ss = input.split(SEPARATOR); long[] r = new long[ss.length]; for (int i = 0; i < ss.length; i++) { r[i] = Long.parseLong(ss[i]); } return r; }  @Nullable @Override long[] apply(@Nullable String input);  }