@Test(expectedExceptions = NullPointerException.class) public void testNullPointer() { new JoinOnComma().apply(null); }
public String apply(Object o) { checkNotNull(o, "input cannot be null"); if (o.getClass().isArray()) { Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < Array.getLength(o); i++) builder.add(Array.get(o, i)); o = builder.build(); } checkArgument(o instanceof Iterable<?>, "you must pass an iterable or array"); Iterable<?> toJoin = (Iterable<?>) o; checkArgument(!Iterables.isEmpty(toJoin), "you must pass an iterable or array with elements"); return Joiner.on(',').join(toJoin); }
JoinOnComma implements Function<Object, String> { public String apply(Object o) { checkNotNull(o, "input cannot be null"); if (o.getClass().isArray()) { Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < Array.getLength(o); i++) builder.add(Array.get(o, i)); o = builder.build(); } checkArgument(o instanceof Iterable<?>, "you must pass an iterable or array"); Iterable<?> toJoin = (Iterable<?>) o; checkArgument(!Iterables.isEmpty(toJoin), "you must pass an iterable or array with elements"); return Joiner.on(',').join(toJoin); } }
JoinOnComma implements Function<Object, String> { public String apply(Object o) { checkNotNull(o, "input cannot be null"); if (o.getClass().isArray()) { Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < Array.getLength(o); i++) builder.add(Array.get(o, i)); o = builder.build(); } checkArgument(o instanceof Iterable<?>, "you must pass an iterable or array"); Iterable<?> toJoin = (Iterable<?>) o; checkArgument(!Iterables.isEmpty(toJoin), "you must pass an iterable or array with elements"); return Joiner.on(',').join(toJoin); }  }
JoinOnComma implements Function<Object, String> { public String apply(Object o) { checkNotNull(o, "input cannot be null"); if (o.getClass().isArray()) { Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < Array.getLength(o); i++) builder.add(Array.get(o, i)); o = builder.build(); } checkArgument(o instanceof Iterable<?>, "you must pass an iterable or array"); Iterable<?> toJoin = (Iterable<?>) o; checkArgument(!Iterables.isEmpty(toJoin), "you must pass an iterable or array with elements"); return Joiner.on(',').join(toJoin); }  String apply(Object o); }
JoinOnComma implements Function<Object, String> { public String apply(Object o) { checkNotNull(o, "input cannot be null"); if (o.getClass().isArray()) { Builder<Object> builder = ImmutableList.builder(); for (int i = 0; i < Array.getLength(o); i++) builder.add(Array.get(o, i)); o = builder.build(); } checkArgument(o instanceof Iterable<?>, "you must pass an iterable or array"); Iterable<?> toJoin = (Iterable<?>) o; checkArgument(!Iterables.isEmpty(toJoin), "you must pass an iterable or array with elements"); return Joiner.on(',').join(toJoin); }  String apply(Object o);  }