public class CustomCollectors {
public static <T> Collector<T, ?, Map<Long, T>> indexing() {
return Collector.of(
HashMap::new,
(map, t) -> map.put(Long.valueOf(map.size() + 1), t),
(left, right) -> {
final long size = left.size();
right.forEach((k, v) -> left.put(k + size, v));
return left;
},
Collector.Characteristics.CONCURRENT
);
}