class 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);
    }

}