@Test void testToLinkedMapDuplicateKey() { Exception exception = assertThrows( IllegalStateException.class, () -> Stream.of("a1", "a2") .collect( MapCollectors.toLinkedMap(str -> str.charAt(0), str -> str.charAt(1)))); assertEquals("Duplicate key detected with values '1' and '2'", exception.getMessage()); }
@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);  }