Collectors.ToUnmodifiableMap Method

Definition

Overloads

ToUnmodifiableMap(IFunction, IFunction, IBinaryOperator)

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

ToUnmodifiableMap(IFunction, IFunction)

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

ToUnmodifiableMap(IFunction, IFunction, IBinaryOperator)

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

[Android.Runtime.Register("toUnmodifiableMap", "(Ljava/util/function/Function;Ljava/util/function/Function;Ljava/util/function/BinaryOperator;)Ljava/util/stream/Collector;", "", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T", "K", "U" })]
public static Java.Util.Streams.ICollector? ToUnmodifiableMap (Java.Util.Functions.IFunction? keyMapper, Java.Util.Functions.IFunction? valueMapper, Java.Util.Functions.IBinaryOperator? mergeFunction);
[<Android.Runtime.Register("toUnmodifiableMap", "(Ljava/util/function/Function;Ljava/util/function/Function;Ljava/util/function/BinaryOperator;)Ljava/util/stream/Collector;", "", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T", "K", "U" })>]
static member ToUnmodifiableMap : Java.Util.Functions.IFunction * Java.Util.Functions.IFunction * Java.Util.Functions.IBinaryOperator -> Java.Util.Streams.ICollector

Parameters

keyMapper
IFunction

a mapping function to produce keys, must be non-null

valueMapper
IFunction

a mapping function to produce values, must be non-null

mergeFunction
IBinaryOperator

a merge function, used to resolve collisions between values associated with the same key, as supplied to Map#merge(Object, Object, BiFunction), must be non-null

Returns

a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements

Attributes

Remarks

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

If the mapped keys contain duplicates (according to Object#equals(Object)), the value mapping function is applied to each equal element, and the results are merged using the provided merging function.

The returned Collector disallows null keys and values. If either mapping function returns null, NullPointerException will be thrown.

Added in 10.

Java documentation for java.util.stream.Collectors.toUnmodifiableMap(java.util.function.Function<? super T, ? extends K>, java.util.function.Function<? super T, ? extends U>, java.util.function.BinaryOperator<U>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

ToUnmodifiableMap(IFunction, IFunction)

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

[Android.Runtime.Register("toUnmodifiableMap", "(Ljava/util/function/Function;Ljava/util/function/Function;)Ljava/util/stream/Collector;", "", ApiSince=33)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T", "K", "U" })]
public static Java.Util.Streams.ICollector? ToUnmodifiableMap (Java.Util.Functions.IFunction? keyMapper, Java.Util.Functions.IFunction? valueMapper);
[<Android.Runtime.Register("toUnmodifiableMap", "(Ljava/util/function/Function;Ljava/util/function/Function;)Ljava/util/stream/Collector;", "", ApiSince=33)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T", "K", "U" })>]
static member ToUnmodifiableMap : Java.Util.Functions.IFunction * Java.Util.Functions.IFunction -> Java.Util.Streams.ICollector

Parameters

keyMapper
IFunction

a mapping function to produce keys, must be non-null

valueMapper
IFunction

a mapping function to produce values, must be non-null

Returns

a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements

Attributes

Remarks

Returns a Collector that accumulates the input elements into an unmodifiable Map, whose keys and values are the result of applying the provided mapping functions to the input elements.

If the mapped keys contain duplicates (according to Object#equals(Object)), an IllegalStateException is thrown when the collection operation is performed. If the mapped keys might have duplicates, use #toUnmodifiableMap(Function, Function, BinaryOperator) to handle merging of the values.

The returned Collector disallows null keys and values. If either mapping function returns null, NullPointerException will be thrown.

Added in 10.

Java documentation for java.util.stream.Collectors.toUnmodifiableMap(java.util.function.Function<? super T, ? extends K>, java.util.function.Function<? super T, ? extends U>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to