T
- Type for values to pass through the channelspublic abstract class StreamCore<T> extends java.lang.Object implements FList<T>
Modifier and Type | Field and Description |
---|---|
protected DataflowVariable<T> |
first |
protected java.util.concurrent.atomic.AtomicReference<StreamCore<T>> |
rest |
protected java.util.Collection<MessageStream> |
wheneverBoundListeners
A collection of listeners who need to be informed each time the stream is bound to a value
|
Modifier | Constructor and Description |
---|---|
protected |
StreamCore(DataflowVariable<T> first)
Creates an empty stream
|
protected |
StreamCore(DataflowVariable<T> first,
groovy.lang.Closure toBeApplied)
Creates a stream while applying the supplied initialization closure to it
|
protected |
StreamCore(DataflowVariable<T> first,
java.util.Collection<MessageStream> wheneverBoundListeners,
java.util.Collection<DataflowChannelListener<T>> updateListeners) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addUpdateListener(DataflowChannelListener<T> updateListener) |
private void |
addUpdateListeners(java.util.Collection<DataflowChannelListener<T>> updateListeners) |
java.lang.String |
appendingString() |
StreamCore<T> |
apply(groovy.lang.Closure closure)
Calls the supplied closure with the stream as a parameter
|
private void |
bind(T value) |
protected abstract StreamCore<T> |
createNewStream()
A factory method to create new instances of the correct class when needed
|
void |
decrementParties()
Decreases the number of parties required to perform the data exchange
|
static <T> T |
eos() |
boolean |
equals(java.lang.Object obj) |
private static <T> T |
eval(java.lang.Object valueOrDataflowVariable) |
FList<T> |
filter(groovy.lang.Closure filterClosure)
Builds a filtered stream using the supplied filter closure
|
private void |
filter(StreamCore<T> rest,
groovy.lang.Closure filterClosure,
StreamCore<T> result) |
StreamCore<T> |
generate(T seed,
groovy.lang.Closure generator,
groovy.lang.Closure condition)
Populates the stream with generated values
|
private void |
generateNext(T value,
StreamCore<T> stream,
groovy.lang.Closure generator,
groovy.lang.Closure condition) |
T |
getFirst()
Retrieved the first element in the stream, blocking until a value is available
|
(package private) DataflowVariable<T> |
getFirstDFV() |
abstract FList<T> |
getRest()
Retrieves a DataflowStream representing the rest of this Stream after removing the first element
|
int |
hashCode() |
private DataflowExpression<T> |
hookWheneverBoundListeners(DataflowExpression<T> expr)
Hooks the registered when bound handlers to the supplied dataflow expression
|
void |
incrementParties()
Increases the number of parties required to perform the data exchange
|
boolean |
isEmpty()
Indicates, whether the first element in the stream is an eos
|
java.util.Iterator<T> |
iterator()
Builds an iterator to iterate over the stream
|
StreamCore<T> |
leftShift(DataflowReadChannel<T> ref)
Adds a dataflow variable value to the stream, once the value is available
|
StreamCore<T> |
leftShift(T value)
Adds a value to the stream
|
FList<java.lang.Object> |
map(groovy.lang.Closure mapClosure)
Builds a modified stream using the supplied map closure
|
private void |
map(FList<T> rest,
groovy.lang.Closure mapClosure,
StreamCore<java.lang.Object> result) |
T |
reduce(groovy.lang.Closure reduceClosure)
Reduces all elements in the stream using the supplied closure
|
T |
reduce(T seed,
groovy.lang.Closure reduceClosure)
Reduces all elements in the stream using the supplied closure
|
private T |
reduce(T current,
FList<T> rest,
groovy.lang.Closure reduceClosure) |
void |
wheneverBound(groovy.lang.Closure closure) |
void |
wheneverBound(MessageStream stream) |
protected final DataflowVariable<T> first
protected final java.util.concurrent.atomic.AtomicReference<StreamCore<T>> rest
protected final java.util.Collection<MessageStream> wheneverBoundListeners
protected StreamCore(DataflowVariable<T> first)
first
- The variable to store as the head of the streamprotected StreamCore(DataflowVariable<T> first, groovy.lang.Closure toBeApplied)
first
- The variable to store as the head of the streamtoBeApplied
- The closure to use for initializationprotected StreamCore(DataflowVariable<T> first, java.util.Collection<MessageStream> wheneverBoundListeners, java.util.Collection<DataflowChannelListener<T>> updateListeners)
private void addUpdateListeners(java.util.Collection<DataflowChannelListener<T>> updateListeners)
final void addUpdateListener(DataflowChannelListener<T> updateListener)
public static <T> T eos()
private static <T> T eval(java.lang.Object valueOrDataflowVariable)
public final StreamCore<T> generate(T seed, groovy.lang.Closure generator, groovy.lang.Closure condition)
seed
- The initial element to evaluate and add as the first value of the streamgenerator
- A closure generating stream elements from the previous valuescondition
- A closure indicating whether the generation should continue based on the last generated valueprivate void generateNext(T value, StreamCore<T> stream, groovy.lang.Closure generator, groovy.lang.Closure condition)
public final StreamCore<T> apply(groovy.lang.Closure closure)
closure
- The closure to callpublic final StreamCore<T> leftShift(DataflowReadChannel<T> ref)
ref
- The DataflowVariable to check for valuepublic final StreamCore<T> leftShift(T value)
value
- The value to addprivate void bind(T value)
final DataflowVariable<T> getFirstDFV()
public final T getFirst()
public abstract FList<T> getRest()
public final boolean isEmpty()
public final FList<T> filter(groovy.lang.Closure filterClosure)
private void filter(StreamCore<T> rest, groovy.lang.Closure filterClosure, StreamCore<T> result)
public final FList<java.lang.Object> map(groovy.lang.Closure mapClosure)
private void map(FList<T> rest, groovy.lang.Closure mapClosure, StreamCore<java.lang.Object> result)
public final T reduce(groovy.lang.Closure reduceClosure)
public final T reduce(T seed, groovy.lang.Closure reduceClosure)
public final java.util.Iterator<T> iterator()
iterator
in interface java.lang.Iterable<T>
public java.lang.String appendingString()
appendingString
in interface FList<T>
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
protected abstract StreamCore<T> createNewStream()
public final void wheneverBound(groovy.lang.Closure closure)
public final void wheneverBound(MessageStream stream)
private DataflowExpression<T> hookWheneverBoundListeners(DataflowExpression<T> expr)
expr
- The expression to hook all the when bound listeners topublic void incrementParties()
public void decrementParties()