Interface Value<T>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default @NotNull Value<T> addRequest()
      Creates a new value with request semantics added.
      T data()
      Retrieves the data payload contained in this value.
      void enter​(java.lang.Object owner)
      Marks the beginning of value processing by a handler.
      default long getRequestDataId()  
      default boolean isClose()
      Checks if this value signals stream/processing closure.
      boolean isData()
      Checks if this value contains processable data.
      default boolean isForce()
      Checks if this value is marked as "force".
      default boolean isOnlyRequestData()  
      default boolean isRequestData()
      Determines if this value represents a data request.
      default Value<T> linkFuture​(io.aether.utils.futures.AFuture res)  
      default Value<T> linkOnRejectExclusive​(ValueExclusiveOnReject.Listener task)
      Attaches an exclusive reject handler that replaces default reject behavior.
      default <T2> Value<T2> map​(io.aether.utils.interfaces.AFunction<T,​T2> mapper)
      Transforms the contained data using a mapping function.
      default <T2> Value<T2> map2​(T2 val)
      Transforms this value into a new value with different data.
      default Value<T> notClose()
      Creates a new value with the same data but not marked as "close".
      static <T> Value<T> of​(T data)
      Creates a simple data-carrying value.
      static <T> Value<T> of​(T data, boolean force, io.aether.utils.interfaces.AConsumer<java.lang.Object> onDrop)
      Creates a value with data, force flag, and success handler.
      static <T> Value<T> of​(T data, boolean force, java.util.Collection<Value<?>> subValues)
      Creates a new value with data, force flag, and sub-values.
      static <T> Value<T> of​(T data, io.aether.utils.interfaces.AConsumer<java.lang.Object> onDrop)
      Creates a data-carrying value with success handler.
      static <T> Value<T> ofClose()
      Creates a stream close value.
      static <K> Value<K> ofForce()
      Creates a generic force-marked value without data.
      static <T> Value<T> ofForce​(T data)
      Creates a force-marked data-carrying value.
      static <T> Value<T> ofForce​(T data, io.aether.utils.interfaces.AConsumer<java.lang.Object> onDrop)
      Creates a force-marked value with data and success handler.
      static <T> @NotNull Value<T> ofRequest()
      Creates a data request value.
      static <T> @NotNull Value<T> ofRequest​(long id)  
      default Value<T> onEnter​(io.aether.utils.interfaces.AConsumer<java.lang.Object> f)
      Attaches a handler to be called when this value enters processing.
      default Value<T> onReject​(ValueOnReject.Listener task)
      Adds an reject handler to be called when this value is rejected.
      default Value<T> onSuccess​(io.aether.utils.interfaces.AConsumer<java.lang.Object> task)
      Adds a success handler to be called when this value is succeed.
      default int priority()
      Returns the processing priority of this value.
      default void reject​(java.lang.Object owner)  
      void reject​(java.lang.Object owner, long blockId)
      Rejects the value sending process due to a stream being blocked.
      void success​(java.lang.Object owner)
      Releases resources associated with this value when it's no longer needed.
      default Value<T> timeout​(long time)
      Sets a processing timeout for this value.
      default Value<T> timeout​(long time, io.aether.utils.interfaces.AConsumer<java.util.concurrent.ConcurrentLinkedQueue<java.lang.Object>> task)
      Enhanced timeout with custom action when timeout occurs.
      default Value<T> withClose()
      Creates a new value with the same data but marked as "close".
      default Value<T> withForce()
      Creates a new value with the same data but marked as "force".
      • Methods inherited from interface io.aether.utils.ToString

        toString, toString2
    • Field Detail

      • BLOCK_COUNTER

        static final java.util.concurrent.atomic.AtomicLong BLOCK_COUNTER
      • FORCE_INSTANCE

        static final Value<?> FORCE_INSTANCE
      • CLOSE_INSTANCE

        static final Value<?> CLOSE_INSTANCE
    • Method Detail

      • data

        T data()
        Retrieves the data payload contained in this value. The actual data type is determined by the generic parameter T.
        Returns:
        The contained data object, which may be null for special values
      • priority

        default int priority()
        Returns the processing priority of this value. Higher priority values should be processed before lower priority ones. Default implementation returns 0 (normal priority).
        Returns:
        Priority level as an integer (higher = more important)
      • isForce

        default boolean isForce()
        Checks if this value is marked as "force". Force values typically bypass normal processing constraints and must be handled immediately regardless of system state.
        Returns:
        true if this is a force value, false otherwise
      • isRequestData

        default boolean isRequestData()
        Determines if this value represents a data request. Request values typically ask for data to be generated/sent rather than containing data themselves.
        Returns:
        true if this is a request value, false otherwise
      • getRequestDataId

        default long getRequestDataId()
      • isClose

        default boolean isClose()
        Checks if this value signals stream/processing closure. Close values typically indicate the end of a data stream or processing sequence.
        Returns:
        true if this is a close signal, false otherwise
      • success

        void success​(java.lang.Object owner)
        Releases resources associated with this value when it's no longer needed. This is the normal end-of-life operation for a value.
        Parameters:
        owner - The object initiating the success operation (for tracking/logging)
      • enter

        void enter​(java.lang.Object owner)
        Marks the beginning of value processing by a handler. Called when a processor starts working with this value.
        Parameters:
        owner - The object that begins processing this value
      • reject

        void reject​(java.lang.Object owner,
                    long blockId)
        Rejects the value sending process due to a stream being blocked.
        Parameters:
        owner - An object that provides information about the current state of the block.

        When the creator of the Value object receives an reject call, it understands that the stream is currently blocked and data cannot be sent at this moment.

        If, at the same time, a Value object with the isRequestData flag arrives from the stream, a race condition can occur. To resolve this issue, the checkWritable method should be called to determine the actual state of the remote node.

        blockId -
      • reject

        default void reject​(java.lang.Object owner)
      • timeout

        default Value<T> timeout​(long time)
        Sets a processing timeout for this value. If the value isn't fully processed (either succeed or rejected) within the specified time, a warning will be logged including information about which processors entered the value.
        Parameters:
        time - Timeout duration in milliseconds
        Returns:
        A new Value instance with timeout tracking behavior
      • timeout

        default Value<T> timeout​(long time,
                                 io.aether.utils.interfaces.AConsumer<java.util.concurrent.ConcurrentLinkedQueue<java.lang.Object>> task)
        Enhanced timeout with custom action when timeout occurs. Similar to timeout(long) but executes the provided task when timeout occurs.
        Parameters:
        time - Timeout duration in milliseconds
        task - Action to execute when timeout occurs, receives enter tracking queue
        Returns:
        A new Value instance with timeout tracking behavior
      • onEnter

        default Value<T> onEnter​(io.aether.utils.interfaces.AConsumer<java.lang.Object> f)
        Attaches a handler to be called when this value enters processing. The original value remains unchanged - returns a new wrapper value.
        Parameters:
        f - Handler to call on enter
        Returns:
        New Value instance with enter handler
      • map2

        default <T2> Value<T2> map2​(T2 val)
        Transforms this value into a new value with different data. Useful for creating derivative values while maintaining the original's lifecycle.
        Parameters:
        val - The new data to wrap
        Returns:
        New Value instance with different data type
      • map

        default <T2> Value<T2> map​(io.aether.utils.interfaces.AFunction<T,​T2> mapper)
        Transforms the contained data using a mapping function. The mapping occurs lazily when data() is first called on the returned value.
        Parameters:
        mapper - Function to transform the contained data
        Returns:
        New Value instance with transformed data
      • linkOnRejectExclusive

        default Value<T> linkOnRejectExclusive​(ValueExclusiveOnReject.Listener task)
        Attaches an exclusive reject handler that replaces default reject behavior. Only this handler will be called when the value is rejected.
        Parameters:
        task - Handler to call exclusively on reject
        Returns:
        New Value instance with exclusive reject handler
      • onReject

        default Value<T> onReject​(ValueOnReject.Listener task)
        Adds an reject handler to be called when this value is rejected. The handler runs in addition to the default reject behavior.
        Parameters:
        task - Handler to call on reject
        Returns:
        New Value instance with additional reject handler
      • onSuccess

        default Value<T> onSuccess​(io.aether.utils.interfaces.AConsumer<java.lang.Object> task)
        Adds a success handler to be called when this value is succeed. The handler runs in addition to the default success behavior.
        Parameters:
        task - Handler to call on success
        Returns:
        New Value instance with additional success handler
      • isData

        boolean isData()
        Checks if this value contains processable data. Returns false for control values (force, request, close).
        Returns:
        true if this value contains data, false otherwise
      • withForce

        default Value<T> withForce()
        Creates a new value with the same data but marked as "force". If this value is already a force value, returns itself.
        Returns:
        Force-marked Value instance
      • withClose

        default Value<T> withClose()
        Creates a new value with the same data but marked as "close". If this value is already a close value, returns itself.
        Returns:
        Close-marked Value instance
      • notClose

        default Value<T> notClose()
        Creates a new value with the same data but not marked as "close". If this value is already not a close value, returns itself.
        Returns:
        Not-close-marked Value instance
      • addRequest

        @NotNull
        default @NotNull Value<T> addRequest()
        Creates a new value with request semantics added. Useful for creating values that both contain data and request more data.
        Returns:
        New Value instance with request flag set
      • isOnlyRequestData

        default boolean isOnlyRequestData()
      • linkFuture

        default Value<T> linkFuture​(io.aether.utils.futures.AFuture res)
      • of

        static <T> Value<T> of​(T data,
                               boolean force,
                               java.util.Collection<Value<?>> subValues)
        Creates a new value with data, force flag, and sub-values. Sub-values allow creating hierarchical value structures.
        Parameters:
        data - The primary data payload
        force - Whether this value should be force-processed
        subValues - Collection of child values
        Returns:
        New Value instance with timeout applied
      • of

        static <T> Value<T> of​(T data)
        Creates a simple data-carrying value.
        Parameters:
        data - The data payload
        Returns:
        New Value instance with timeout applied
      • ofForce

        static <T> Value<T> ofForce​(T data)
        Creates a force-marked data-carrying value.
        Parameters:
        data - The data payload
        Returns:
        New force-marked Value instance with timeout applied
      • of

        static <T> Value<T> of​(T data,
                               io.aether.utils.interfaces.AConsumer<java.lang.Object> onDrop)
        Creates a data-carrying value with success handler.
        Parameters:
        data - The data payload
        onDrop - Handler to call when value is succeed
        Returns:
        New Value instance with success handler and timeout
      • of

        static <T> Value<T> of​(T data,
                               boolean force,
                               io.aether.utils.interfaces.AConsumer<java.lang.Object> onDrop)
        Creates a value with data, force flag, and success handler.
        Parameters:
        data - The data payload
        force - Whether this value should be force-processed
        onDrop - Handler to call when value is succeed
        Returns:
        New Value instance with specified properties and timeout
      • ofForce

        static <T> Value<T> ofForce​(T data,
                                    io.aether.utils.interfaces.AConsumer<java.lang.Object> onDrop)
        Creates a force-marked value with data and success handler.
        Parameters:
        data - The data payload
        onDrop - Handler to call when value is succeed
        Returns:
        New force-marked Value instance with success handler and timeout
      • ofForce

        static <K> Value<K> ofForce()
        Creates a generic force-marked value without data.
        Returns:
        Singleton force value instance
      • ofRequest

        @NotNull
        static <T> @NotNull Value<T> ofRequest()
        Creates a data request value.
        Returns:
        Singleton request value instance
      • ofRequest

        @NotNull
        static <T> @NotNull Value<T> ofRequest​(long id)
      • ofClose

        static <T> Value<T> ofClose()
        Creates a stream close value.
        Returns:
        Singleton close value instance