public abstract class Accumulator<E,A>
extends java.lang.Object
map
, recover
and so on are
provided for the eventually redeemed future value.
In order to be in line with the Java ecosystem, the future implementation that this uses for the materialised value
of the Sink is java.util.concurrent.CompletionStage, and running this accumulator will yield a CompletionStage. The
constructor allows an accumulator to be created from such a sink. Many methods in the Akka streams API however
materialise a scala.concurrent.Future, hence the fromSink
method is provided to create an accumulator
from a typical Akka streams Sink
.Modifier and Type | Method and Description |
---|---|
abstract play.api.libs.streams.Accumulator<E,A> |
asScala()
Convert this accumulator to a Scala accumulator.
|
static <E,A> Accumulator<E,A> |
done(A a)
Create a done accumulator with the given value.
|
static <E,A> Accumulator<E,A> |
done(java.util.concurrent.CompletionStage<A> a)
Create a done accumulator with the given future.
|
static <E,A> Accumulator<E,A> |
flatten(java.util.concurrent.CompletionStage<Accumulator<E,A>> stage,
akka.stream.Materializer materializer)
Flatten a completion stage of an accumulator to an accumulator.
|
static <E,A> Accumulator<E,A> |
fromSink(akka.stream.javadsl.Sink<E,java.util.concurrent.CompletionStage<A>> sink)
Create an accumulator from an Akka streams sink.
|
abstract <B> Accumulator<E,B> |
map(java.util.function.Function<? super A,? extends B> f,
java.util.concurrent.Executor executor)
Map the accumulated value.
|
abstract <B> Accumulator<E,B> |
mapFuture(java.util.function.Function<? super A,? extends java.util.concurrent.CompletionStage<B>> f,
java.util.concurrent.Executor executor)
Map the accumulated value with a function that returns a future.
|
abstract Accumulator<E,A> |
recover(java.util.function.Function<? super java.lang.Throwable,? extends A> f,
java.util.concurrent.Executor executor)
Recover from any errors encountered by the accumulator.
|
abstract Accumulator<E,A> |
recoverWith(java.util.function.Function<? super java.lang.Throwable,? extends java.util.concurrent.CompletionStage<A>> f,
java.util.concurrent.Executor executor)
Recover from any errors encountered by the accumulator.
|
abstract java.util.concurrent.CompletionStage<A> |
run(akka.stream.Materializer mat)
Run the accumulator with an empty source.
|
abstract java.util.concurrent.CompletionStage<A> |
run(akka.stream.javadsl.Source<E,?> source,
akka.stream.Materializer mat)
Run the accumulator with the given source.
|
static <E> Accumulator<E,akka.stream.javadsl.Source<E,?>> |
source()
Create an accumulator that forwards the stream fed into it to the source it produces.
|
abstract <D> Accumulator<D,A> |
through(akka.stream.javadsl.Flow<D,E,?> flow)
Pass the stream through the given flow before forwarding it to the accumulator.
|
abstract akka.stream.javadsl.Sink<E,java.util.concurrent.CompletionStage<A>> |
toSink()
Convert this accumulator to a sink.
|
public abstract <B> Accumulator<E,B> map(java.util.function.Function<? super A,? extends B> f, java.util.concurrent.Executor executor)
B
- the mapped value typef
- The function to perform the map with.executor
- The executor to run the function in.public abstract <B> Accumulator<E,B> mapFuture(java.util.function.Function<? super A,? extends java.util.concurrent.CompletionStage<B>> f, java.util.concurrent.Executor executor)
B
- the mapped value typef
- The function to perform the map with.executor
- The executor to run the function in.public abstract Accumulator<E,A> recover(java.util.function.Function<? super java.lang.Throwable,? extends A> f, java.util.concurrent.Executor executor)
f
- The function to use to recover from errors.executor
- The executor to run the function in.public abstract Accumulator<E,A> recoverWith(java.util.function.Function<? super java.lang.Throwable,? extends java.util.concurrent.CompletionStage<A>> f, java.util.concurrent.Executor executor)
f
- The function to use to recover from errors.executor
- The executor to run the function in.public abstract <D> Accumulator<D,A> through(akka.stream.javadsl.Flow<D,E,?> flow)
D
- the "In" type for the flow parameter.flow
- The flow to send the stream through first.public abstract java.util.concurrent.CompletionStage<A> run(akka.stream.Materializer mat)
mat
- The flow materializer.public abstract java.util.concurrent.CompletionStage<A> run(akka.stream.javadsl.Source<E,?> source, akka.stream.Materializer mat)
source
- The source to feed into the accumulator.mat
- The flow materializer.public abstract akka.stream.javadsl.Sink<E,java.util.concurrent.CompletionStage<A>> toSink()
public abstract play.api.libs.streams.Accumulator<E,A> asScala()
public static <E,A> Accumulator<E,A> fromSink(akka.stream.javadsl.Sink<E,java.util.concurrent.CompletionStage<A>> sink)
E
- the "in" type of the sink parameter.A
- the materialized result of the accumulator.sink
- The sink.public static <E> Accumulator<E,akka.stream.javadsl.Source<E,?>> source()
E
- the "in" type of the parameter.public static <E,A> Accumulator<E,A> done(A a)
E
- the "in" type of the parameter.A
- the materialized result of the accumulator.a
- The done value for the accumulator.public static <E,A> Accumulator<E,A> done(java.util.concurrent.CompletionStage<A> a)
E
- the "in" type of the parameter.A
- the materialized result of the accumulator.a
- A future of the done value.public static <E,A> Accumulator<E,A> flatten(java.util.concurrent.CompletionStage<Accumulator<E,A>> stage, akka.stream.Materializer materializer)
E
- the "in" type of the parameter.A
- the materialized result of the accumulator.stage
- the CompletionStage (asynchronous) accumulatormaterializer
- the stream materializer