MoreCollectors { public static <K, V> Collector<Entry<K, V>, ?, Map<K, V>> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); } private  MoreCollectors(); static Collector<Integer, ?, IntArrayList> toIntList(); static Collector<Long, ?, LongArrayList> toLongList(); static Collector<Integer, ?, IntHashSet> toIntSet(); static Collector<Long, ?, LongHashSet> toLongSet(); static Collector<T, IntObjectHashMap<U>, IntObjectHashMap<U>> toIntMap(
            ToIntFunction<? super T> keyMapper, Function<? super T, ? extends U> valueMapper); static Collector<Entry<K, V>, ?, Map<K, V>> toMap(); @Deprecated static Collector<T, ?, HashMultiset<K>> toMultiset(
            Function<? super T, ? extends K> elementMapper, ToIntFunction<? super T> countMapper); @Deprecated static Collector<T, ?, M> toMultimap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper, Supplier<M> supplier); static Collector<T, ?, R> toMap(
            Function<? super T, ? extends K> keyMapper,
            Function<? super T, ? extends U> valueMapper, Supplier<R> supplier); static Collector<T, ?, Map<K, List<T>>> groupingByAllowNullKey(
            Function<? super T, ? extends K> classifier); static Collector<T, ?, Map<K, D>> groupingByAllowNullKey(
            Function<? super T, ? extends K> classifier,
            Collector<? super T, A, D> downstream); static Collector<T, ?, M> groupingByAllowNullKey(
            Function<? super T, ? extends K> classifier,
            Supplier<M> mapFactory,
            Collector<? super T, A, D> downstream); static BinaryOperator<T> throwingMerger(); @Deprecated static Collector<T, ?, Stream<T>> concat(Stream<? extends T> other); @Deprecated static Collector<T, ?, Stream<T>> concat(T element); static final Set<Collector.Characteristics> CH_ID; static final Set<Collector.Characteristics> CH_NOID; }
@Test void toMapTest() { Map<Integer, TestEnum1> map = Stream.of(TestEnum1.values()).collect(toMap(TestEnum1::getValue, identity())); assertEquals(4, map.size()); assertNotNull(map.get(null)); }