public class Channels extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Channels.Selectable<DATA>
Data class storing information about the origin of the data.
|
static interface |
Channels.SelectableOutputChannel<OUT>
Interface defining a selectable output channel, that is a channel filtering selectable data
and dispatching them to a specific output channel based on their index.
|
| Modifier and Type | Method and Description |
|---|---|
static <IN,OUT> StreamingChannel<IN,OUT> |
asyncStream(Routine<IN,OUT> routine)
Creates and returns a new streaming channel by invoking the specified routine in asynchronous
mode.
|
static IOChannel<Channels.Selectable<?>,Channels.Selectable<?>> |
combine(Channel.InputChannel<?>... channels)
Combines the specified channels into a selectable one.
|
static IOChannel<Channels.Selectable<?>,Channels.Selectable<?>> |
combine(int startIndex,
Channel.InputChannel<?>... channels)
Combines the specified channels into a selectable one.
Note that the returned channel must be explicitly closed in order to ensure the completion of the invocation lifecycle. |
static <IN> IOChannel<Channels.Selectable<? extends IN>,Channels.Selectable<? extends IN>> |
combine(int startIndex,
List<? extends Channel.InputChannel<? extends IN>> channels)
Combines the specified channels into a selectable one.
Note that the returned channel must be explicitly closed in order to ensure the completion of the invocation lifecycle. |
static <IN> IOChannel<Channels.Selectable<? extends IN>,Channels.Selectable<? extends IN>> |
combine(List<? extends Channel.InputChannel<? extends IN>> channels)
Combines the specified channels into a selectable one.
|
static <IN> IOChannel<Channels.Selectable<? extends IN>,Channels.Selectable<? extends IN>> |
combine(Map<Integer,? extends Channel.InputChannel<? extends IN>> channels)
Combines the specified channels into a selectable one.
Note that the returned channel must be explicitly closed in order to ensure the completion of the invocation lifecycle. |
static IOChannel<List<?>,List<?>> |
distribute(Channel.InputChannel<?>... channels)
Returns a new channel distributing the input data among the specified channels.
|
static <IN> IOChannel<List<? extends IN>,List<? extends IN>> |
distribute(List<? extends Channel.InputChannel<? extends IN>> channels)
Returns a new channel distributing the input data among the specified channels.
|
static IOChannel<List<?>,List<?>> |
distributeAndFlush(Channel.InputChannel<?>... channels)
Returns a new channel distributing the input data among the specified channels.
|
static <IN> IOChannel<List<? extends IN>,List<? extends IN>> |
distributeAndFlush(List<? extends Channel.InputChannel<? extends IN>> channels)
Returns a new channel distributing the input data among the specified channels.
|
static Channel.OutputChannel<List<?>> |
join(Channel.OutputChannel<?>... channels)
Returns an output channel joining the data coming from the specified list of channels.
An output will be generated only when at least one result is available for each channel. Note that the channels will be bound as a result of the call. |
static <OUT> Channel.OutputChannel<List<? extends OUT>> |
join(List<? extends Channel.OutputChannel<? extends OUT>> channels)
Returns an output channel joining the data coming from the specified list of channels.
An output will be generated only when at least one result is available for each channel. Note that the channels will be bound as a result of the call. |
static Channel.OutputChannel<List<?>> |
joinAndFlush(Channel.OutputChannel<?>... channels)
Returns an output channel joining the data coming from the specified list of channels.
An output will be generated only when at least one result is available for each channel. |
static <OUT> Channel.OutputChannel<List<? extends OUT>> |
joinAndFlush(List<? extends Channel.OutputChannel<? extends OUT>> channels)
Returns an output channel joining the data coming from the specified list of channels.
An output will be generated only when at least one result is available for each channel. |
static Channel.OutputChannel<? extends Channels.Selectable<?>> |
merge(Channel.OutputChannel<?>... channels)
Merges the specified channels into a selectable one.
|
static Channel.OutputChannel<? extends Channels.Selectable<?>> |
merge(int startIndex,
Channel.OutputChannel<?>... channels)
Merges the specified channels into a selectable one.
Note that the channels will be bound as a result of the call. |
static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> |
merge(int startIndex,
List<? extends Channel.OutputChannel<? extends OUT>> channels)
Merges the specified channels into a selectable one.
Note that the channels will be bound as a result of the call. |
static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> |
merge(List<? extends Channel.OutputChannel<? extends OUT>> channels)
Merges the specified channels into a selectable one.
|
static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> |
merge(Map<Integer,? extends Channel.OutputChannel<? extends OUT>> channelMap)
Merges the specified channels into a selectable one.
Note that the channels will be bound as a result of the call. |
static <IN,OUT> StreamingChannel<IN,OUT> |
parallelStream(Routine<IN,OUT> routine)
Creates and returns a new streaming channel by invoking the specified routine in parallel
mode.
|
static <DATA,IN extends DATA> |
select(Channel.InputChannel<? super Channels.Selectable<DATA>> channel,
int... indexes)
Returns a map of input channels accepting the input data identified by the specified indexes.
|
static <DATA,IN extends DATA> |
select(Channel.InputChannel<? super Channels.Selectable<DATA>> channel,
int index)
Returns a new channel transforming the input data into selectable ones.
Note that the returned channel must be explicitly closed in order to ensure the completion of the invocation lifecycle. |
static <DATA,IN extends DATA> |
select(Channel.InputChannel<? super Channels.Selectable<DATA>> channel,
Iterable<Integer> indexes)
Returns a map of input channels accepting the input data identified by the specified indexes.
|
static <OUT> Channels.SelectableOutputChannel<OUT> |
select(Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel)
Returns a selectable output filtering the data coming from the specified channel.
Note that the channel will be bound as a result of the call, the method, though, can be safely called more than once for the same selectable channel. |
static <OUT> Map<Integer,Channel.OutputChannel<OUT>> |
select(Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel,
int... indexes)
Returns a map of output channels returning the outputs filtered by the specified indexes.
|
static <OUT> Map<Integer,Channel.OutputChannel<OUT>> |
select(Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel,
Iterable<Integer> indexes)
Returns a map of output channels returning the output data filtered by the specified indexes.
|
static <DATA,IN extends DATA> |
select(int startIndex,
int rangeSize,
Channel.InputChannel<? super Channels.Selectable<DATA>> channel)
Returns a map of input channels accepting the input data identified by the specified indexes.
|
static <OUT> Map<Integer,Channel.OutputChannel<OUT>> |
select(int startIndex,
int rangeSize,
Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel)
Returns a map of output channels returning the output data filtered by the specified indexes.
|
static <IN,OUT> StreamingChannel<IN,OUT> |
stream(IOChannel<IN,?> inputChannel,
Channel.OutputChannel<OUT> outputChannel)
Creates and returns a new streaming channel backed by the specified input and output.
Note that it is up to the caller ensure that the specified input and output channels are actually connected. |
static <IN,OUT> StreamingChannel<IN,OUT> |
syncStream(Routine<IN,OUT> routine)
Creates and returns a new streaming channel by invoking the specified routine in synchronous
mode.
|
static <IN> IOChannel<Channels.Selectable<IN>,Channels.Selectable<IN>> |
toSelectable(Channel.InputChannel<? super IN> channel,
int index)
Returns a new selectable channel feeding the specified one.
Each output will be filtered based on the specified index. Note that the returned channel must be explicitly closed in order to ensure the completion of the invocation lifecycle. |
static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> |
toSelectable(Channel.OutputChannel<? extends OUT> channel,
int index)
Returns a new channel making the specified one selectable.
Each output will be passed along unchanged. Note that the channel will be bound as a result of the call. |
@NotNull public static <IN,OUT> StreamingChannel<IN,OUT> asyncStream(@NotNull Routine<IN,OUT> routine)
IN - the input data type.OUT - the output data type.routine - the routine to be invoked.@NotNull public static IOChannel<Channels.Selectable<?>,Channels.Selectable<?>> combine(@NotNull Channel.InputChannel<?>... channels)
channels - the array of input channels.IllegalArgumentException - if the specified array is empty.@NotNull public static IOChannel<Channels.Selectable<?>,Channels.Selectable<?>> combine(int startIndex, @NotNull Channel.InputChannel<?>... channels)
startIndex - the selectable start index.channels - the array of input channels.IllegalArgumentException - if the specified array is empty.@NotNull public static <IN> IOChannel<Channels.Selectable<? extends IN>,Channels.Selectable<? extends IN>> combine(int startIndex, @NotNull List<? extends Channel.InputChannel<? extends IN>> channels)
IN - the input data type.startIndex - the selectable start index.channels - the list of input channels.IllegalArgumentException - if the specified list is empty.@NotNull public static <IN> IOChannel<Channels.Selectable<? extends IN>,Channels.Selectable<? extends IN>> combine(@NotNull List<? extends Channel.InputChannel<? extends IN>> channels)
IN - the input data type.channels - the list of input channels.IllegalArgumentException - if the specified list is empty.@NotNull public static <IN> IOChannel<Channels.Selectable<? extends IN>,Channels.Selectable<? extends IN>> combine(@NotNull Map<Integer,? extends Channel.InputChannel<? extends IN>> channels)
IN - the input data type.channels - the map of indexes and input channels.IllegalArgumentException - if the specified map is empty.@NotNull public static IOChannel<List<?>,List<?>> distribute(@NotNull Channel.InputChannel<?>... channels)
channels - the array of channels.IllegalArgumentException - if the specified array is empty.@NotNull public static <IN> IOChannel<List<? extends IN>,List<? extends IN>> distribute(@NotNull List<? extends Channel.InputChannel<? extends IN>> channels)
IN - the input data type.channels - the list of channels.IllegalArgumentException - if the specified list is empty.@NotNull public static IOChannel<List<?>,List<?>> distributeAndFlush(@NotNull Channel.InputChannel<?>... channels)
channels - the array of channels.IllegalArgumentException - if the specified array is empty.@NotNull public static <IN> IOChannel<List<? extends IN>,List<? extends IN>> distributeAndFlush(@NotNull List<? extends Channel.InputChannel<? extends IN>> channels)
IN - the input data type.channels - the list of channels.IllegalArgumentException - if the specified list is empty.@NotNull public static <OUT> Channel.OutputChannel<List<? extends OUT>> join(@NotNull List<? extends Channel.OutputChannel<? extends OUT>> channels)
OUT - the output data type.channels - the list of channels.IllegalArgumentException - if the specified list is empty.@NotNull public static Channel.OutputChannel<List<?>> join(@NotNull Channel.OutputChannel<?>... channels)
channels - the array of channels.IllegalArgumentException - if the specified array is empty.@NotNull public static <OUT> Channel.OutputChannel<List<? extends OUT>> joinAndFlush(@NotNull List<? extends Channel.OutputChannel<? extends OUT>> channels)
OUT - the output data type.channels - the list of channels.IllegalArgumentException - if the specified list is empty.@NotNull public static Channel.OutputChannel<List<?>> joinAndFlush(@NotNull Channel.OutputChannel<?>... channels)
channels - the array of channels.IllegalArgumentException - if the specified array is empty.@NotNull public static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> merge(int startIndex, @NotNull List<? extends Channel.OutputChannel<? extends OUT>> channels)
OUT - the output data type.startIndex - the selectable start index.channels - the list of channels.IllegalArgumentException - if the specified list is empty.@NotNull public static Channel.OutputChannel<? extends Channels.Selectable<?>> merge(int startIndex, @NotNull Channel.OutputChannel<?>... channels)
startIndex - the selectable start index.channels - the array of channels.IllegalArgumentException - if the specified array is empty.@NotNull public static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> merge(@NotNull List<? extends Channel.OutputChannel<? extends OUT>> channels)
OUT - the output data type.channels - the channels to merge.IllegalArgumentException - if the specified list is empty.@NotNull public static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> merge(@NotNull Map<Integer,? extends Channel.OutputChannel<? extends OUT>> channelMap)
OUT - the output data type.channelMap - the map of indexes and output channels.IllegalArgumentException - if the specified map is empty.@NotNull public static Channel.OutputChannel<? extends Channels.Selectable<?>> merge(@NotNull Channel.OutputChannel<?>... channels)
channels - the channels to merge.IllegalArgumentException - if the specified array is empty.@NotNull public static <IN,OUT> StreamingChannel<IN,OUT> parallelStream(@NotNull Routine<IN,OUT> routine)
IN - the input data type.OUT - the output data type.routine - the routine to be invoked.@NotNull public static <DATA,IN extends DATA> IOChannel<IN,IN> select(@Nullable Channel.InputChannel<? super Channels.Selectable<DATA>> channel, int index)
DATA - the channel data type.IN - the input data type.channel - the selectable channel.index - the channel index.@NotNull public static <DATA,IN extends DATA> Map<Integer,IOChannel<IN,IN>> select(@NotNull Channel.InputChannel<? super Channels.Selectable<DATA>> channel, @NotNull Iterable<Integer> indexes)
DATA - the channel data type.IN - the input data type.channel - the selectable channel.indexes - the iterable returning the channel indexes.@NotNull public static <DATA,IN extends DATA> Map<Integer,IOChannel<IN,IN>> select(@NotNull Channel.InputChannel<? super Channels.Selectable<DATA>> channel, @NotNull int... indexes)
DATA - the channel data type.IN - the input data type.channel - the selectable channel.indexes - the array of indexes.@NotNull public static <DATA,IN extends DATA> Map<Integer,IOChannel<IN,IN>> select(int startIndex, int rangeSize, @NotNull Channel.InputChannel<? super Channels.Selectable<DATA>> channel)
DATA - the channel data type.IN - the input data type.startIndex - the selectable start index.rangeSize - the size of the range of indexes (must be positive).channel - the selectable channel.IllegalArgumentException - if the specified range size is negative or 0.@NotNull public static <OUT> Map<Integer,Channel.OutputChannel<OUT>> select(int startIndex, int rangeSize, @NotNull Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel)
OUT - the output data type.startIndex - the selectable start index.rangeSize - the size of the range of indexes (must be positive).channel - the selectable channel.IllegalArgumentException - if the specified range size is negative or 0.@NotNull public static <OUT> Channels.SelectableOutputChannel<OUT> select(@NotNull Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel)
OUT - the output data type.channel - the selectable output channel.@NotNull public static <OUT> Map<Integer,Channel.OutputChannel<OUT>> select(@NotNull Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel, @NotNull int... indexes)
OUT - the output data type.channel - the selectable output channel.indexes - the list of indexes.@NotNull public static <OUT> Map<Integer,Channel.OutputChannel<OUT>> select(@NotNull Channel.OutputChannel<? extends Channels.Selectable<? extends OUT>> channel, @NotNull Iterable<Integer> indexes)
OUT - the output data type.channel - the selectable output channel.indexes - the iterable returning the channel indexes.@NotNull public static <IN,OUT> StreamingChannel<IN,OUT> stream(@NotNull IOChannel<IN,?> inputChannel, @NotNull Channel.OutputChannel<OUT> outputChannel)
IN - the input data type.OUT - the output data type.inputChannel - the input channel.outputChannel - the output channel.@NotNull public static <IN,OUT> StreamingChannel<IN,OUT> syncStream(@NotNull Routine<IN,OUT> routine)
IN - the input data type.OUT - the output data type.routine - the routine to be invoked.@NotNull public static <IN> IOChannel<Channels.Selectable<IN>,Channels.Selectable<IN>> toSelectable(@Nullable Channel.InputChannel<? super IN> channel, int index)
IN - the input data type.channel - the channel to make selectable.index - the channel index.@NotNull public static <OUT> Channel.OutputChannel<? extends Channels.Selectable<OUT>> toSelectable(@Nullable Channel.OutputChannel<? extends OUT> channel, int index)
OUT - the output data type.channel - the channel to make selectable.index - the channel index.