java.lang.Object
net.pincette.rs.Accumulator<T,U>
- All Implemented Interfaces:
Flow.Subscriber<T>
Accumulates a publisher and when that's done it calls the provided function. With the
get
method you obtain the final result.- Since:
- 1.3
- Author:
- Werner Donné
-
Constructor Summary
ConstructorDescriptionAccumulator
(Function<Stream<T>, CompletionStage<U>> reducer) Constructs the accumulator with a reducer.Accumulator
(Function<Stream<T>, CompletionStage<U>> reducer, UnaryOperator<T> copy) Constructs the accumulator with a reducer. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
U> Flow.Subscriber<T> accumulator
(Function<Stream<T>, CompletionStage<U>> reducer) static <T,
U> Flow.Subscriber<T> accumulator
(Function<Stream<T>, CompletionStage<U>> reducer, UnaryOperator<T> copy) get()
Returns the reduced value when the stage is complete.void
void
void
void
onSubscribe
(Flow.Subscription subscription)
-
Constructor Details
-
Accumulator
Constructs the accumulator with a reducer.- Parameters:
reducer
- the reducer function.- Since:
- 1.3
-
Accumulator
Constructs the accumulator with a reducer.- Parameters:
reducer
- the reducer function.copy
- the function that copies the values before they are accumulated. It may benull
.- Since:
- 3.0.1
-
-
Method Details
-
accumulator
-
accumulator
public static <T,U> Flow.Subscriber<T> accumulator(Function<Stream<T>, CompletionStage<U>> reducer, UnaryOperator<T> copy) -
get
Returns the reduced value when the stage is complete.- Returns:
- The stage to received the reduced value.
- Since:
- 1.3
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceFlow.Subscriber<T>
-
onError
- Specified by:
onError
in interfaceFlow.Subscriber<T>
-
onNext
- Specified by:
onNext
in interfaceFlow.Subscriber<T>
-
onSubscribe
- Specified by:
onSubscribe
in interfaceFlow.Subscriber<T>
-