@Test public void testSingleton() { final String[] as = singleton(String.class).apply("1"); assertEquals("1", as[0]); }
public static <A> Function<A, A[]> singleton(final Class<A> type) { return new Function<A, A[]>() { @Override public A[] apply(A a) { @SuppressWarnings("unchecked") final A[] as = (A[]) Array.newInstance(type, 1); as[0] = a; return as; } }; }
Arrays { public static <A> Function<A, A[]> singleton(final Class<A> type) { return new Function<A, A[]>() { @Override public A[] apply(A a) { @SuppressWarnings("unchecked") final A[] as = (A[]) Array.newInstance(type, 1); as[0] = a; return as; } }; } }
Arrays { public static <A> Function<A, A[]> singleton(final Class<A> type) { return new Function<A, A[]>() { @Override public A[] apply(A a) { @SuppressWarnings("unchecked") final A[] as = (A[]) Array.newInstance(type, 1); as[0] = a; return as; } }; } private  Arrays(); }
Arrays { public static <A> Function<A, A[]> singleton(final Class<A> type) { return new Function<A, A[]>() { @Override public A[] apply(A a) { @SuppressWarnings("unchecked") final A[] as = (A[]) Array.newInstance(type, 1); as[0] = a; return as; } }; } private  Arrays(); static A[] cons(Class<A> type, A a, A[] as); static A[] append(Class<A> type, A[] as, A a); static A[] array(A... as); static Function<A, A[]> singleton(final Class<A> type); static String mkString(A[] as, String sep); }
Arrays { public static <A> Function<A, A[]> singleton(final Class<A> type) { return new Function<A, A[]>() { @Override public A[] apply(A a) { @SuppressWarnings("unchecked") final A[] as = (A[]) Array.newInstance(type, 1); as[0] = a; return as; } }; } private  Arrays(); static A[] cons(Class<A> type, A a, A[] as); static A[] append(Class<A> type, A[] as, A a); static A[] array(A... as); static Function<A, A[]> singleton(final Class<A> type); static String mkString(A[] as, String sep);  }