public <K> FlowToMap<K, List<B>, FlowGroup<K, B>> toMap(Supplier<Map<K, FlowGroup<K, B>>> groupMapSupplier, Mapper<B, K> toKey) { return toMap(groupMapSupplier, toKey, Flow.<K, B>flowGroupListMapper()); }
public FlowToMap<K, List<T>, B> toMap() { return toMap(Flow.<K, T>flowGroupListMapper()); }
public FlowToMap<K, List<T>, B> toMap() { return toMap(Flow.<K, T>flowGroupListMapper()); }
public <K> FlowToMap<K, List<B>, FlowGroup<K, B>> toMap(Supplier<Map<K, FlowGroup<K, B>>> groupMapSupplier, Mapper<B, K> toKey) { return toMap(groupMapSupplier, toKey, Flow.<K, B>flowGroupListMapper()); }
@Test public void test_toMap() { Map<Boolean, List<Integer>> map = Flow.of(1, 2, 3) .toMap(new Mapper<Integer, Boolean>() { @Override public Boolean map(Integer integer) { return integer % 2 == 0; } }, Flow.<Boolean, Integer>flowGroupListMapper()) .get(); Assert.assertEquals(2, map.size()); Assert.assertEquals(1, map.get(true).size()); Assert.assertEquals(Integer.valueOf(2), map.get(true).get(0)); Assert.assertEquals(2, map.get(false).size()); Assert.assertEquals(Integer.valueOf(1), map.get(false).get(0)); Assert.assertEquals(Integer.valueOf(3), map.get(false).get(1)); }