Package io.aether.utils.streams
Class BufferNode<TRead,TWrite>
- java.lang.Object
-
- io.aether.utils.streams.BufferNode<TRead,TWrite>
-
- Type Parameters:
TWrite- The type of data written to the buffer.TRead- The type of data read from the buffer.
- All Implemented Interfaces:
io.aether.utils.interfaces.ObjectFind,Node<TWrite,TRead,TRead,TWrite>,NodeDown<TWrite,TRead>,NodeUp<TRead,TWrite>,io.aether.utils.ToString
- Direct Known Subclasses:
BufferNodeAutoFlush
public class BufferNode<TRead,TWrite> extends java.lang.Object implements Node<TWrite,TRead,TRead,TWrite>, io.aether.utils.interfaces.ObjectFind
Represents a node in a stream that buffers incoming data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBufferNode.BGate<TIn,TOut>Represents a buffer gate that can send and receive data.classBufferNode.BGateDownRepresents a buffer gate for sending data downwards.classBufferNode.BGateUpRepresents a buffer gate for sending data upwards.
-
Constructor Summary
Constructors Constructor Description BufferNode()Constructs a newBufferNodewith initialized up and down gates.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description FGate<TRead,TWrite>gDown()Returns the gate for sending data downwards.FGate<TWrite,TRead>gUp()Returns the gate for sending data upwards.protected BufferNode.BGateDowninitDown()Initializes the downBufferNode.BGate.protected BufferNode.BGateUpinitUp()Initializes the upBufferNode.BGate.booleanisEmpty()Checks if both the up and down buffers are empty.booleanisEmptyToDown()Checks if the buffer for sending data downwards is empty.booleanisEmptyToUp()Checks if the buffer for sending data upwards is empty.static <TUp,TDown>
BufferNode<TUp,TDown>of()Creates a newBufferNodewith default settings.static <TUp,TDown>
BufferNode<TUp,TDown>of(Gate<TDown,TUp> g)Creates a newBufferNodeand links it to the provided gate.voidpause()Pauses both upwards and downwards data sending.voidpauseDown()Pauses sending data downwards.voidpauseUp()Pauses sending data upwards.voidresume()Resumes both upwards and downwards data sending.voidresumeDown()Resumes sending data downwards.voidresumeUp()Resumes sending data upwards.java.lang.StringtoString()Returns a string representation of this node.voidtoString(io.aether.utils.AString sb)Appends a string representation of this node to the providedAString.
-
-
-
Constructor Detail
-
BufferNode
public BufferNode()
Constructs a newBufferNodewith initialized up and down gates.
-
-
Method Detail
-
isEmpty
public boolean isEmpty()
Checks if both the up and down buffers are empty.- Returns:
- true if both buffers are empty, false otherwise
-
isEmptyToUp
public boolean isEmptyToUp()
Checks if the buffer for sending data upwards is empty.- Returns:
- true if the up buffer is empty, false otherwise
-
isEmptyToDown
public boolean isEmptyToDown()
Checks if the buffer for sending data downwards is empty.- Returns:
- true if the down buffer is empty, false otherwise
-
toString
public void toString(io.aether.utils.AString sb)
Appends a string representation of this node to the providedAString.- Specified by:
toStringin interfaceio.aether.utils.ToString- Parameters:
sb- theAStringto append to
-
toString
public java.lang.String toString()
Returns a string representation of this node.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string representation
-
resumeUp
public void resumeUp()
Resumes sending data upwards.
-
resumeDown
public void resumeDown()
Resumes sending data downwards.
-
resume
public void resume()
Resumes both upwards and downwards data sending.
-
pauseUp
public void pauseUp()
Pauses sending data upwards.
-
pauseDown
public void pauseDown()
Pauses sending data downwards.
-
pause
public void pause()
Pauses both upwards and downwards data sending.
-
initUp
protected BufferNode.BGateUp initUp()
Initializes the upBufferNode.BGate.- Returns:
- a new instance of
BufferNode.BGateUp
-
initDown
protected BufferNode.BGateDown initDown()
Initializes the downBufferNode.BGate.- Returns:
- a new instance of
BufferNode.BGateDown
-
of
public static <TUp,TDown> BufferNode<TUp,TDown> of()
Creates a newBufferNodewith default settings.- Type Parameters:
TUp- the type of data written to the bufferTDown- the type of data read from the buffer- Returns:
- a new instance of
BufferNode
-
of
public static <TUp,TDown> BufferNode<TUp,TDown> of(Gate<TDown,TUp> g)
Creates a newBufferNodeand links it to the provided gate.- Type Parameters:
TUp- the type of data written to the bufferTDown- the type of data read from the buffer- Parameters:
g- the gate to link- Returns:
- a new instance of
BufferNode
-
-