T - The type of the valuesC - The composable subclass through which the values can be consumedpublic class Deferred<T,C extends Composable<T>> extends java.lang.Object implements Consumer<T>
accept(Object) and accept(Throwable) respectively. Values can be consumed using the read-only
Composable subclass made available by compose().
Typical usage is to create a Deferred and store it internally, only providing the
enclosed Composable to clients. This ensures that clients can only consume values
and cannot break the contract by also supplying them.| Constructor and Description |
|---|
Deferred(C composable)
Creates a new Deferred using the given
Composable |
Deferred(C head,
C tail)
Creates a new Deferred using decoupled given head and tail
Composable |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(T value)
Accepts the given
value such that it can be consumed by the underlying
Composable. |
void |
accept(java.lang.Throwable error)
Accepts the given
error such that it can be consumed by the
underlying Composable. |
void |
acceptEvent(Event<T> value)
Accepts the given
value such that it can be consumed by the underlying
Composable. |
BufferAction<T> |
batcher()
|
BufferAction<T> |
batcher(int batchSize)
|
C |
compose()
Returns the underlying
Composable subclass from which values and errors can be
consumed. |
void |
flush()
Flush the
Composable such that it can trigger batch operations. |
public Deferred(C composable)
Composablecomposable - The composable that will provide access to valuespublic Deferred(C head, C tail)
Composablehead - The composable that will provide access to valuestail - The composable that will be used for consumptionpublic void accept(java.lang.Throwable error)
error such that it can be consumed by the
underlying Composable.error - The error to acceptpublic void accept(T value)
value such that it can be consumed by the underlying
Composable.public BufferAction<T> batcher()
Consumer that accepts a sequence of events before
notifying the Composable whom must be a Streampublic BufferAction<T> batcher(int batchSize)
Consumer that accepts a sequence of events before
notifying the Composable whom must be a StreambatchSize - the explicit batch size to usepublic void acceptEvent(Event<T> value)
value such that it can be consumed by the underlying
Composable.value - The value to acceptpublic void flush()
Composable such that it can trigger batch operations.public C compose()
Composable subclass from which values and errors can be
consumed.