public FlowCollectAndSort<B, List<B>> toSortedList(List<B> list) { return then(new FlowCollectAndSort<B, List<B>>(list)); }
@Test public void test_sorted_list() { List<Integer> result = Flow.of(3, 2, 1).toSortedList().get(); Assert.assertEquals(3, result.size()); Assert.assertEquals(Integer.valueOf(1), result.get(0)); Assert.assertEquals(Integer.valueOf(2), result.get(1)); Assert.assertEquals(Integer.valueOf(3), result.get(2)); }
@Test public void test_grouping_3() { List<Integer> result = Flow.of(1, 2, 3) .groupBy(new Mapper<Integer, Boolean>() { @Override public Boolean map(Integer it) { return it % 2 == 0; } }) .flatMap(new Mapper<FlowGroup<Boolean, Integer>, FlowProcessOnEnd<?, Integer>>() { @Override public FlowProcessOnEnd<?, Integer> map(FlowGroup<Boolean, Integer> group) { return group.first(); } }) .toSortedList() .get(); Assert.assertEquals(2, result.size()); Assert.assertEquals(Integer.valueOf(1), result.get(0)); Assert.assertEquals(Integer.valueOf(2), result.get(1)); }
public FlowCollectAndSort<B, List<B>> toSortedList(List<B> list) { return then(new FlowCollectAndSort<B, List<B>>(list)); }