Dela via


Collectors.CollectingAndThen(ICollector, IFunction) Method

Definition

Adapts a Collector to perform an additional finishing transformation.

[Android.Runtime.Register("collectingAndThen", "(Ljava/util/stream/Collector;Ljava/util/function/Function;)Ljava/util/stream/Collector;", "", ApiSince=24)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T", "A", "R", "RR" })]
public static Java.Util.Streams.ICollector? CollectingAndThen (Java.Util.Streams.ICollector? downstream, Java.Util.Functions.IFunction? finisher);
[<Android.Runtime.Register("collectingAndThen", "(Ljava/util/stream/Collector;Ljava/util/function/Function;)Ljava/util/stream/Collector;", "", ApiSince=24)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T", "A", "R", "RR" })>]
static member CollectingAndThen : Java.Util.Streams.ICollector * Java.Util.Functions.IFunction -> Java.Util.Streams.ICollector

Parameters

downstream
ICollector

a collector

finisher
IFunction

a function to be applied to the final result of the downstream collector

Returns

a collector which performs the action of the downstream collector, followed by an additional finishing step

Attributes

Remarks

Adapts a Collector to perform an additional finishing transformation. For example, one could adapt the #toList() collector to always produce an immutable list with:

{@code
            List<String> list = people.stream().collect(
              collectingAndThen(toList(),
                                Collections::unmodifiableList));
            }

Java documentation for java.util.stream.Collectors.collectingAndThen(java.util.stream.Collector<T, A, R>, java.util.function.Function<R, RR>).

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