@Test void testToLinkedMap() { Map<String, Integer> expectedLinkedMap = new LinkedHashMap<>(); expectedLinkedMap.put("a", 1); expectedLinkedMap.put("bb", 2); expectedLinkedMap.put("ccc", 3); Map<String, Integer> actualLinkedMap = Stream.of("a", "bb", "ccc").collect(MapCollectors.toLinkedMap(identity(), String::length)); assertEquals(actualLinkedMap, expectedLinkedMap); }
@SuppressWarnings("java:S1452") public static <T, K, U> Collector<T, ?, Map<K, U>> toLinkedMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) { return Collectors.toMap(keyMapper, valueMapper, throwingMerger(), LinkedHashMap::new); }
MapCollectors { @SuppressWarnings("java:S1452") public static <T, K, U> Collector<T, ?, Map<K, U>> toLinkedMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) { return Collectors.toMap(keyMapper, valueMapper, throwingMerger(), LinkedHashMap::new); } }
MapCollectors { @SuppressWarnings("java:S1452") public static <T, K, U> Collector<T, ?, Map<K, U>> toLinkedMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) { return Collectors.toMap(keyMapper, valueMapper, throwingMerger(), LinkedHashMap::new); } private  MapCollectors(); }
MapCollectors { @SuppressWarnings("java:S1452") public static <T, K, U> Collector<T, ?, Map<K, U>> toLinkedMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) { return Collectors.toMap(keyMapper, valueMapper, throwingMerger(), LinkedHashMap::new); } private  MapCollectors(); @SuppressWarnings("java:S1452") static Collector<T, ?, Map<K, U>> toLinkedMap(
      Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper); }
MapCollectors { @SuppressWarnings("java:S1452") public static <T, K, U> Collector<T, ?, Map<K, U>> toLinkedMap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) { return Collectors.toMap(keyMapper, valueMapper, throwingMerger(), LinkedHashMap::new); } private  MapCollectors(); @SuppressWarnings("java:S1452") static Collector<T, ?, Map<K, U>> toLinkedMap(
      Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper);  }