@Test @SuppressWarnings("unchecked") public void chain() { final List<Map<String, Object>> stooges = new ArrayList<Map<String, Object>>() { { add(new LinkedHashMap<String, Object>() { { put("name", "curly"); put("age", 25); } }); add(new LinkedHashMap<String, Object>() { { put("name", "moe"); put("age", 21); } }); add(new LinkedHashMap<String, Object>() { { put("name", "larry"); put("age", 23); } }); } }; final String youngest = Chaining.chain(stooges) .sortBy( new Function<Map<String, Object>, Integer>() { public Integer apply(Map<String, Object> item) { return (Integer) item.get("age"); } }) .map( new Function<Map<String, Object>, String>() { public String apply(Map<String, Object> item) { return item.get("name") + " is " + item.get("age"); } }) .first().item(); assertEquals("moe is 21", youngest); }
public static <T> Chain<T> chain(final List<T> list) { return new Chaining.Chain<T>(list); }
Chaining { public static <T> Chain<T> chain(final List<T> list) { return new Chaining.Chain<T>(list); } }
Chaining { public static <T> Chain<T> chain(final List<T> list) { return new Chaining.Chain<T>(list); }  }
Chaining { public static <T> Chain<T> chain(final List<T> list) { return new Chaining.Chain<T>(list); }  static E first(final Iterable<E> iterable); static List<T> map(final List<E> list, final Function<? super E, T> func); static List<E> sortBy(final List<E> iterable,
        final Function<E, T> func); static Chain<T> chain(final List<T> list); }
Chaining { public static <T> Chain<T> chain(final List<T> list) { return new Chaining.Chain<T>(list); }  static E first(final Iterable<E> iterable); static List<T> map(final List<E> list, final Function<? super E, T> func); static List<E> sortBy(final List<E> iterable,
        final Function<E, T> func); static Chain<T> chain(final List<T> list);  }