MCPcopy Index your code
hub / github.com/google/dagger / toImmutableMap

Method toImmutableMap

java/dagger/internal/codegen/DaggerStreams.java:56–65  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 1

dependencyEdgesMethod · 0.80

Calls 4

buildMethod · 0.65
applyMethod · 0.45
ofMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected