IN - The input type.OUT - The output type.public class Node<IN,OUT> extends java.lang.Object implements InputNode<IN>, OutputNode<OUT>
Node is a base class for all nodes.| Modifier and Type | Field and Description |
|---|---|
protected Graph<?> |
graph |
protected java.util.ArrayList<InputNode<OUT>> |
inputNodes |
| Modifier | Constructor and Description |
|---|---|
protected |
Node()
Constructs a new instance of
Node. |
| Modifier and Type | Method and Description |
|---|---|
<T> Node<OUT,T> |
action(Action action)
|
<T> Node<OUT,T> |
action(Action1<OUT> action)
|
protected InputNode<OUT> |
addInputNode(InputNode<OUT> inputNode)
|
InputNode<OUT> |
attach(InputNode<OUT> inputNode)
Attaches the given
InputNode to this OutputNode. |
static <OUT> OutputActionNode<OUT> |
begin(OutputAction<OUT> action)
Creates an
OutputActionNode for the given OutputAction. |
static <OUT> RequestNode<OUT,OUT> |
begin(RequestDelegate<OUT> delegate)
Creates an
RequestNode for the given RequestDelegate. |
static <OUT> TimerNode<OUT> |
beginTimer(OUT input,
long delay)
Creates a
TimerNode with the given input value and delay. |
static <OUT> TimerNode<OUT> |
beginTimer(OUT input,
long delay,
long interval,
int repeatCount)
Creates a
TimerNode with the given input value and parameters. |
Node<OUT,OUT> |
buffer(int capacity)
Attaches a
BufferNode with the given capacity to this Node. |
protected void |
completed(OutputNode<?> source)
Invoked to notify all
InputNodes about completion. |
Node<OUT,OUT> |
concat(OutputNode<OUT>... sources)
Attaches a
ConcatNode to the current OutputNode. |
Node<OUT,java.lang.String> |
concatStrings()
Attaches a
ConcatStringsNode to this Node. |
Node<OUT,java.lang.Integer> |
count()
|
protected java.lang.String |
createErrorMessage(java.lang.String message,
java.lang.String... args)
Creates and formats an error message.
|
void |
detach(InputNode<OUT> inputNode)
Detaches the given
InputNode from this OutputNode. |
protected void |
dispatchError(OutputNode<?> source,
java.lang.Throwable throwable)
Dispatches an error to all
InputNodes, if any. |
protected void |
dispatchReset()
Dispatches a resetting to all
InputNodes, if any. |
Node<OUT,OUT> |
distinct()
Attaches a
DistinctNode to this Node. |
protected void |
doOnCompleted(OutputNode<?> source)
Invoked by
InputNode.onCompleted(OutputNode). |
protected void |
doOnError(OutputNode<?> source,
java.lang.Throwable throwable)
Invoked by
InputNode.onCompleted(OutputNode). |
protected void |
doOnInput(OutputNode<IN> source,
IN input)
Invoked by
InputNode.onInput(OutputNode, Object) when the given input Object
has been received from the OutputNode that emitted it. |
protected void |
doOnReset()
Invoked by
InputNode.onCompleted(OutputNode). |
void |
emitOutput()
Invoked to emit available output value(s) from this
OutputNode. |
protected void |
emitOutput(OUT output)
Invoked to emit the given output to attached
InputNodes, if any. |
Node<OUT,OUT> |
filter(BooleanFunction<OUT> condition)
|
Node<OUT,OUT> |
first()
|
Node<OUT,OUT> |
first(BooleanFunction<OUT> condition)
|
Graph<?> |
getGraph()
|
boolean |
hasInputNodes()
Tests if this
OutputNode has any attached @link InputNode}s. |
boolean |
isErrorReceived()
Tests if an error has been received.
|
Node<OUT,OUT> |
last()
|
Node<OUT,OUT> |
last(BooleanFunction<OUT> condition)
|
<T> Node<OUT,T> |
map(Function<OUT,T> function)
|
Node<OUT,OUT> |
merge(OutputNode<OUT>... sources)
Attaches a
MergeNode to the current OutputNode. |
Node<OUT,OUT> |
nth(int steps)
|
Node<OUT,OUT> |
observer(NodeObserver<OUT> observer)
|
<T> Node<OUT,T> |
observer(RequestDelegate<T> delegate)
|
protected void |
onAttached(InputNode<OUT> inputNode)
|
void |
onCompleted(OutputNode<?> source)
Invoked when the specified source
OutputNode is completed. |
protected void |
onDetached(InputNode<OUT> inputNode)
|
void |
onError(OutputNode<?> source,
java.lang.Throwable throwable)
Invoked when the given source
OutputNode has detected an error. |
void |
onInput(OutputNode<IN> source,
IN input)
Invoked by the given source
OutputNode for this InputNode to receive the input
Object that was emitted by the OutputNode. |
void |
onReset()
Invoked to reset this
Node. |
protected OUT |
processInput(OutputNode<IN> source,
IN input)
Invoked by
InputNode.onInput(OutputNode, Object) when the given input Object
has been received from the OutputNode that emitted it. |
protected void |
removeInputNode(InputNode<OUT> inputNode)
|
Node<OUT,OUT> |
repeat(int times)
Attaches a
RepeatNode with the given times parameter to this Node. |
Node<OUT,OUT> |
reverse()
Attaches a
ReverseNode to this Node. |
protected void |
setErrorReceived(boolean errorReceived)
Sets the flag that indicates if an error is received.
|
void |
setGraph(Graph<?> graph)
|
Node<OUT,OUT> |
skip(int steps)
|
Node<OUT,OUT> |
skipWhile(BooleanFunction<OUT> condition)
|
void |
start()
Invokes the begin node of the
Graph to emit its value(s). |
Node<OUT,java.lang.String> |
string()
Attaches a
StringNode to this Node. |
Node<OUT,java.lang.Double> |
sum()
|
Node<OUT,OUT> |
take(int steps)
|
Node<OUT,OUT> |
timer(long delay)
|
Node<OUT,OUT> |
timer(long delay,
long interval,
int repeatCount)
|
Node<OUT,java.lang.Boolean> |
toBoolean()
Attaches a
BooleanNode to this Node. |
Node<OUT,java.lang.Byte> |
toByte()
|
Node<OUT,java.lang.Character> |
toChar()
Attaches a
CharacterNode to this Node. |
Node<OUT,java.lang.Double> |
toDouble()
Attaches a
DoubleNode to this Node. |
Node<OUT,java.lang.Float> |
toFloat()
|
Node<OUT,java.lang.Integer> |
toInt()
Attaches an
IntegerNode to this Node. |
Node<OUT,java.lang.Long> |
toLong()
|
Node<OUT,OUT> |
toMain()
Transfers the execution to the main thread by attaching a
ThreadNode. |
Node<OUT,java.lang.Short> |
toShort()
|
<T> Node<OUT,OUT> |
toWorker()
Transfers the execution to a worker thread by attaching a
ThreadNode. |
static ViewNode |
whenClicked(android.view.View view)
Creates an
ViewNode for the given View. |
static TextViewNode |
whenTextChanged(android.widget.TextView textView)
Creates an
TextViewNode for the given TextView. |
protected Graph<?> graph
protected Node()
Node.public static <OUT> OutputActionNode<OUT> begin(OutputAction<OUT> action)
OutputActionNode for the given OutputAction.action - A OutputAction.OutputActionNode.public static <OUT> RequestNode<OUT,OUT> begin(RequestDelegate<OUT> delegate)
RequestNode for the given RequestDelegate.delegate - A RequestDelegate.RequestNode.public static <OUT> TimerNode<OUT> beginTimer(OUT input, long delay)
TimerNode with the given input value and delay.input - The input value.delay - The delay in milliseconds.RequestNode.public static <OUT> TimerNode<OUT> beginTimer(OUT input, long delay, long interval, int repeatCount)
TimerNode with the given input value and parameters.input - The input value.delay - The delay in milliseconds.interval - The interval in milliseconds for repeated timeouts.repeatCount - The number of repeats.RequestNode.public static ViewNode whenClicked(android.view.View view)
ViewNode for the given View.view - A View.ViewNode.public static TextViewNode whenTextChanged(android.widget.TextView textView)
TextViewNode for the given TextView.textView - A TextView.TextViewNode.public boolean isErrorReceived()
boolean.protected void setErrorReceived(boolean errorReceived)
errorReceived - A boolean.protected void emitOutput(OUT output)
InputNodes, if any.output - The outbut Object.protected void completed(OutputNode<?> source)
InputNodes about completion.source - The completed OutputNode.protected void dispatchError(OutputNode<?> source, java.lang.Throwable throwable)
InputNodes, if any.source - The OutputNode that has detected the error.throwable - A Throwable representing the error.public InputNode<OUT> attach(InputNode<OUT> inputNode)
OutputNodeInputNode to this OutputNode.attach in interface OutputNode<OUT>inputNode - An InputNode.InputNode.protected void onAttached(InputNode<OUT> inputNode)
inputNode - The attached InputNode.public void detach(InputNode<OUT> inputNode)
OutputNodeInputNode from this OutputNode.detach in interface OutputNode<OUT>inputNode - An InputNode.protected void removeInputNode(InputNode<OUT> inputNode)
inputNode - A InputNode.protected void onDetached(InputNode<OUT> inputNode)
inputNode - The detached InputNode.public boolean hasInputNodes()
OutputNode has any attached @link InputNode}s.boolean value.public void emitOutput()
OutputNodeOutputNode.emitOutput in interface OutputNode<OUT>public void onReset()
Node.protected void dispatchReset()
InputNodes, if any.protected void doOnReset()
InputNode.onCompleted(OutputNode). This method can be overridden
in subclasses for hooking on the reset events.public void onInput(OutputNode<IN> source, IN input)
InputNodeOutputNode for this InputNode to receive the input
Object that was emitted by the OutputNode.protected void doOnInput(OutputNode<IN> source, IN input)
InputNode.onInput(OutputNode, Object) when the given input Object
has been received from the OutputNode that emitted it. This method can be overridden
in subclasses for hooking on the input received events.source - An OutputNode that emitted the input.input - The input Object.protected OUT processInput(OutputNode<IN> source, IN input)
InputNode.onInput(OutputNode, Object) when the given input Object
has been received from the OutputNode that emitted it.source - An OutputNode that emitted the input.input - The input Object.public void onCompleted(OutputNode<?> source)
InputNodeOutputNode is completed.onCompleted in interface InputNode<IN>source - The completed OutputNode.protected void doOnCompleted(OutputNode<?> source)
InputNode.onCompleted(OutputNode). This method can be overridden
in subclasses for hooking on the completed events.source - An OutputNode that was completed.public void onError(OutputNode<?> source, java.lang.Throwable throwable)
InputNodeOutputNode has detected an error.onError in interface InputNode<IN>source - The OutputNode notifying about error.throwable - A Throwable representing the detected error.protected void doOnError(OutputNode<?> source, java.lang.Throwable throwable)
InputNode.onCompleted(OutputNode). This method can be overridden
in subclasses for hooking on the error received events.source - The OutputNode notifying about error.throwable - A Throwable representing the error.public void start()
Graph to emit its value(s).protected java.lang.String createErrorMessage(java.lang.String message,
java.lang.String... args)
message - The error message as a String. May contain place holders for formatting.args - Optional formats args.String.public Node<OUT,OUT> buffer(int capacity)
BufferNode with the given capacity to this Node.Node.@SafeVarargs public final Node<OUT,OUT> concat(OutputNode<OUT>... sources)
ConcatNode to the current OutputNode.Node.public Node<OUT,java.lang.String> concatStrings()
ConcatStringsNode to this Node.Node.public Node<OUT,OUT> distinct()
DistinctNode to this Node.Node.public Node<OUT,OUT> filter(BooleanFunction<OUT> condition)
condition - A BooleanFunction.Node.public Node<OUT,OUT> first(BooleanFunction<OUT> condition)
condition - A BooleanFunction.Node.public Node<OUT,OUT> last(BooleanFunction<OUT> condition)
condition - A BooleanFunction.Node.@SafeVarargs public final Node<OUT,OUT> merge(OutputNode<OUT>... sources)
MergeNode to the current OutputNode.Node.public Node<OUT,OUT> nth(int steps)
steps - The index value.Node.public Node<OUT,OUT> observer(NodeObserver<OUT> observer)
observer - A NodeObserver.Node.public Node<OUT,OUT> repeat(int times)
RepeatNode with the given times parameter to this Node.times - The times parameter.Node.public <T> Node<OUT,T> observer(RequestDelegate<T> delegate)
delegate - A RequestDelegate.Node.public Node<OUT,OUT> reverse()
ReverseNode to this Node.Node.public Node<OUT,OUT> skip(int steps)
steps - The steps value.Node.public Node<OUT,OUT> skipWhile(BooleanFunction<OUT> condition)
condition - A BooleanFunction.Node.public Node<OUT,java.lang.String> string()
StringNode to this Node.Node.public Node<OUT,OUT> take(int steps)
steps - The steps value.Node.public Node<OUT,OUT> timer(long delay)
delay - The delay in milliseconds.Node.public Node<OUT,OUT> timer(long delay, long interval, int repeatCount)
delay - The delay in milliseconds.interval - The interval in milliseconds for repeated timeouts.repeatCount - The number of repeats.Node.public Node<OUT,java.lang.Boolean> toBoolean()
BooleanNode to this Node.Node.public Node<OUT,java.lang.Character> toChar()
CharacterNode to this Node.Node.public Node<OUT,java.lang.Double> toDouble()
DoubleNode to this Node.Node.public Node<OUT,java.lang.Integer> toInt()
IntegerNode to this Node.Node.public Node<OUT,OUT> toMain()
ThreadNode.Node.public <T> Node<OUT,OUT> toWorker()
ThreadNode.Node.