@Test public void eachテスト() { final List<String> elements = Lists.gen("a", "b", "c", "d", "e"); final int[] datum = {0, elements.size()}; Lists.each(elements, new EachCall<String>() { public void each(String element, int index, int total) { Assert.assertEquals(elements.get(index), element); Assert.assertEquals(datum[0]++, index); Assert.assertEquals(datum[1], total); } }); }
public static <T> List<T> each(List<T> elements, EachCall<T> callback) { if (elements == null || callback == null || elements.size() == 0) return Collections.<T>emptyList(); int index = 0; int total = elements.size(); for (T t : elements) { callback.each(t, index++, total); } return elements; }
Lists { public static <T> List<T> each(List<T> elements, EachCall<T> callback) { if (elements == null || callback == null || elements.size() == 0) return Collections.<T>emptyList(); int index = 0; int total = elements.size(); for (T t : elements) { callback.each(t, index++, total); } return elements; } }
Lists { public static <T> List<T> each(List<T> elements, EachCall<T> callback) { if (elements == null || callback == null || elements.size() == 0) return Collections.<T>emptyList(); int index = 0; int total = elements.size(); for (T t : elements) { callback.each(t, index++, total); } return elements; } private  Lists(); }
Lists { public static <T> List<T> each(List<T> elements, EachCall<T> callback) { if (elements == null || callback == null || elements.size() == 0) return Collections.<T>emptyList(); int index = 0; int total = elements.size(); for (T t : elements) { callback.each(t, index++, total); } return elements; } private  Lists(); static List<T> gen(T... elements); static List<T> gen(int size, GenCall<T> generator); static U gen(int size, Class<U> container, GenCall<T> generator); static List<T> each(List<T> elements, EachCall<T> callback); static List<T> collect(List<T> elements, CollectCall<T> callback); static Map<String, List<T>> group(List<T> elements, GroupCall<T> callback); static boolean isEmpty(List<T> suspect); static PartialList<T> emptyPartialList(); }
Lists { public static <T> List<T> each(List<T> elements, EachCall<T> callback) { if (elements == null || callback == null || elements.size() == 0) return Collections.<T>emptyList(); int index = 0; int total = elements.size(); for (T t : elements) { callback.each(t, index++, total); } return elements; } private  Lists(); static List<T> gen(T... elements); static List<T> gen(int size, GenCall<T> generator); static U gen(int size, Class<U> container, GenCall<T> generator); static List<T> each(List<T> elements, EachCall<T> callback); static List<T> collect(List<T> elements, CollectCall<T> callback); static Map<String, List<T>> group(List<T> elements, GroupCall<T> callback); static boolean isEmpty(List<T> suspect); static PartialList<T> emptyPartialList(); @SuppressWarnings("rawtypes")
    static final PartialList EMPTY_PARTIAL_LIST; }