Returns a Collector that accumulates elements into an ImmutableMap whose keys and values are the result of applying the provided mapping functions to the input elements. Entries appear in the result ImmutableMap in encounter order.
(
Function<? super T, K> keyMapper, Function<? super T, V> valueMapper)
| 54 | * Entries appear in the result {@code ImmutableMap} in encounter order. |
| 55 | */ |
| 56 | public static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap( |
| 57 | Function<? super T, K> keyMapper, Function<? super T, V> valueMapper) { |
| 58 | return Collectors.mapping( |
| 59 | value -> Maps.immutableEntry(keyMapper.apply(value), valueMapper.apply(value)), |
| 60 | Collector.of( |
| 61 | ImmutableMap::builder, |
| 62 | (ImmutableMap.Builder<K, V> builder, Map.Entry<K, V> entry) -> builder.put(entry), |
| 63 | (left, right) -> left.putAll(right.build()), |
| 64 | ImmutableMap.Builder::build)); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Returns a function from {@link Object} to {@code Stream<T>}, which returns a stream containing |
no test coverage detected