Class 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
      class  BufferNode.BGate<TIn,​TOut>
      Represents a buffer gate that can send and receive data.
      class  BufferNode.BGateDown
      Represents a buffer gate for sending data downwards.
      class  BufferNode.BGateUp
      Represents a buffer gate for sending data upwards.
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferNode()
      Constructs a new BufferNode with 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.BGateDown initDown()
      Initializes the down BufferNode.BGate.
      protected BufferNode.BGateUp initUp()
      Initializes the up BufferNode.BGate.
      boolean isEmpty()
      Checks if both the up and down buffers are empty.
      boolean isEmptyToDown()
      Checks if the buffer for sending data downwards is empty.
      boolean isEmptyToUp()
      Checks if the buffer for sending data upwards is empty.
      static <TUp,​TDown>
      BufferNode<TUp,​TDown>
      of()
      Creates a new BufferNode with default settings.
      static <TUp,​TDown>
      BufferNode<TUp,​TDown>
      of​(Gate<TDown,​TUp> g)
      Creates a new BufferNode and links it to the provided gate.
      void pause()
      Pauses both upwards and downwards data sending.
      void pauseDown()
      Pauses sending data downwards.
      void pauseUp()
      Pauses sending data upwards.
      void resume()
      Resumes both upwards and downwards data sending.
      void resumeDown()
      Resumes sending data downwards.
      void resumeUp()
      Resumes sending data upwards.
      java.lang.String toString()
      Returns a string representation of this node.
      void toString​(io.aether.utils.AString sb)
      Appends a string representation of this node to the provided AString.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface io.aether.utils.streams.NodeDown

        up
      • Methods inherited from interface io.aether.utils.interfaces.ObjectFind

        find, find, getOwners
      • Methods inherited from interface io.aether.utils.ToString

        toString2
    • Constructor Detail

      • BufferNode

        public BufferNode()
        Constructs a new BufferNode with 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 provided AString.
        Specified by:
        toString in interface io.aether.utils.ToString
        Parameters:
        sb - the AString to append to
      • toString

        public java.lang.String toString()
        Returns a string representation of this node.
        Overrides:
        toString in class java.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.
      • of

        public static <TUp,​TDown> BufferNode<TUp,​TDown> of()
        Creates a new BufferNode with default settings.
        Type Parameters:
        TUp - the type of data written to the buffer
        TDown - 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 new BufferNode and links it to the provided gate.
        Type Parameters:
        TUp - the type of data written to the buffer
        TDown - the type of data read from the buffer
        Parameters:
        g - the gate to link
        Returns:
        a new instance of BufferNode