public class TransformingSendPort<T> extends DelegatingSendPort<T>
target| Modifier and Type | Method and Description |
|---|---|
<U> TransformingSendPort<U> |
fiberTransform(FiberFactory fiberFactory,
SuspendableAction2<? extends ReceivePort<? super U>,? extends SendPort<? extends T>> transformer,
Channel<U> in)
Spawns a fiber that transforms values read from the
in channel and writes values to this channel. |
<U> TransformingSendPort<U> |
fiberTransform(SuspendableAction2<? extends ReceivePort<? super U>,? extends SendPort<? extends T>> transformer,
Channel<U> in)
Spawns a fiber that transforms values read from the
in channel and writes values to this channel. |
TransformingSendPort<T> |
filter(com.google.common.base.Predicate<T> pred)
Returns a
TransformingSendPort that filters messages that satisfy a predicate before sending to this channel. |
<S> TransformingSendPort<S> |
flatMap(Channel<S> pipe,
com.google.common.base.Function<S,ReceivePort<T>> f)
Returns a
SendPort that sends messages that are transformed by a given flat-mapping function into this channel. |
<S> TransformingSendPort<S> |
map(com.google.common.base.Function<S,T> f)
Returns a
TransformingSendPort that transforms messages by applying a given mapping function before sending this channel. |
<S> TransformingSendPort<S> |
reduce(Function2<T,S,T> f,
T init)
Returns a
TransformingSendPort to which sending messages that are transformed towards a channel by a reduction function. |
close, close, equals, hashCode, send, send, send, toString, trySendclone, finalize, getClass, notify, notifyAll, wait, wait, waitisClosedpublic TransformingSendPort<T> filter(com.google.common.base.Predicate<T> pred)
TransformingSendPort that filters messages that satisfy a predicate before sending to this channel.
Messages that don't satisfy the predicate will be silently discarded when sent.
The returned SendPort has the same hashCode as channel and is equal to it.pred - the filtering predicateTransformingSendPort that will send only those messages which satisfy the predicate (i.e. the predicate returns true) to the given channel.public <S> TransformingSendPort<S> map(com.google.common.base.Function<S,T> f)
TransformingSendPort that transforms messages by applying a given mapping function before sending this channel.
The returned TransformingSendPort has the same hashCode as channel and is equal to it.f - the mapping functionTransformingSendPort that passes messages to the given channel after transforming them by applying the mapping function.public <S> TransformingSendPort<S> reduce(Function2<T,S,T> f, T init)
TransformingSendPort to which sending messages that are transformed towards a channel by a reduction function.
The returned TransformingSendPort has the same hashCode as channel and is equal to it.f - The reduction function.init - The initial input to the reduction function.ReceivePort that returns messages that are the result of applying the reduction function to the messages received on the given channel.public <S> TransformingSendPort<S> flatMap(Channel<S> pipe, com.google.common.base.Function<S,ReceivePort<T>> f)
SendPort that sends messages that are transformed by a given flat-mapping function into this channel.
Unlike map, the mapping function does not returns a single output message for every input message, but
a new ReceivePort. All the returned ports are concatenated and sent to the channel.
To return a single value the mapping function can make use of Channels.singletonReceivePort(Object). To return a collection,
it can make use of Channels.toReceivePort(Iterable). To emit no values, the function can return Channels.emptyReceivePort()
or null.
If multiple producers send messages into the channel, the messages from the ReceivePorts returned by the mapping function
may be interleaved with other messages.
The returned SendPort has the same hashCode as channel and is equal to it.pipe - an intermediate channel used in the flat-mapping operation. Messages are first sent to this channel before being transformed.f - the mapping functionReceivePort that returns messages that are the result of applying the mapping function to the messages received on the given channel.public <U> TransformingSendPort<U> fiberTransform(SuspendableAction2<? extends ReceivePort<? super U>,? extends SendPort<? extends T>> transformer, Channel<U> in)
in channel and writes values to this channel.
When the transformation terminates. the output channel is automatically closed. If the transformation terminates abnormally
(throws an exception), this channel is closed with that exception.in - the input channeltransformer - the transforming operationTransformingSendPort wrapping the in channel.public <U> TransformingSendPort<U> fiberTransform(FiberFactory fiberFactory, SuspendableAction2<? extends ReceivePort<? super U>,? extends SendPort<? extends T>> transformer, Channel<U> in)
in channel and writes values to this channel.
When the transformation terminates. the output channel is automatically closed. If the transformation terminates abnormally
(throws an exception), this channel is closed with that exception.fiberFactory - will be used to create the fiberin - the input channeltransformer - the transforming operationTransformingSendPort wrapping the in channel.