@Test void ensureOrderIsPreserved() { final List<String> expected = asList("a", "b", "c"); assertIterableEquals(expected, expected.stream().collect(toLinkedMap(identity(), identity())).keySet()); }
public static <T, K, V> Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap( final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper) { return toMap(keyMapper, valueMapper, (v1, v2) -> { throw new IllegalArgumentException("conflict on key " + v1); }, LinkedHashMap::new); }
CustomCollectors { public static <T, K, V> Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap( final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper) { return toMap(keyMapper, valueMapper, (v1, v2) -> { throw new IllegalArgumentException("conflict on key " + v1); }, LinkedHashMap::new); } }
CustomCollectors { public static <T, K, V> Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap( final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper) { return toMap(keyMapper, valueMapper, (v1, v2) -> { throw new IllegalArgumentException("conflict on key " + v1); }, LinkedHashMap::new); }  }
CustomCollectors { public static <T, K, V> Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap( final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper) { return toMap(keyMapper, valueMapper, (v1, v2) -> { throw new IllegalArgumentException("conflict on key " + v1); }, LinkedHashMap::new); }  static Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap(
            final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper); }
CustomCollectors { public static <T, K, V> Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap( final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper) { return toMap(keyMapper, valueMapper, (v1, v2) -> { throw new IllegalArgumentException("conflict on key " + v1); }, LinkedHashMap::new); }  static Collector<T, ?, LinkedHashMap<K, V>> toLinkedMap(
            final Function<? super T, ? extends K> keyMapper, final Function<? super T, ? extends V> valueMapper);  }