Interface Sink<T>

All Superinterfaces:
Consumer<T>

public interface Sink<T> extends Consumer<T>
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    accept(double value)
    Accepts a double value.
    default void
    accept(int value)
    Accepts an int value.
    default void
    accept(long value)
    Accepts a long value.
    default void
    begin(long size)
    Resets the sink state to receive a fresh data set.
    default boolean
    Indicates that this Sink does not wish to receive any more data.
    default void
    end()
    Indicates that all elements have been pushed.

    Methods inherited from interface java.util.function.Consumer

    accept, andThen
  • Method Details

    • begin

      default void begin(long size)
      Resets the sink state to receive a fresh data set. This must be called before sending any data to the sink. After calling end(), you may call this method to reset the sink for another calculation.
      Parameters:
      size - The exact size of the data to be pushed downstream, if known or -1 if unknown or infinite.

      Prior to this call, the sink must be in the initial state, and after this call it is in the active state.

    • end

      default void end()
      Indicates that all elements have been pushed. If the Sink is stateful, it should send any stored state downstream at this time, and should clear any accumulated state (and associated resources).

      Prior to this call, the sink must be in the active state, and after this call it is returned to the initial state.

    • cancellationRequested

      default boolean cancellationRequested()
      Indicates that this Sink does not wish to receive any more data.

      Note: The default implementation always returns false.

      Returns:
      true if cancellation is requested
    • accept

      default void accept(int value)
      Accepts an int value.

      Note: The default implementation throws IllegalStateException.

      Throws:
      IllegalStateException - if this sink does not accept int values
    • accept

      default void accept(long value)
      Accepts a long value.

      Note: The default implementation throws IllegalStateException.

      Throws:
      IllegalStateException - if this sink does not accept long values
    • accept

      default void accept(double value)
      Accepts a double value.

      Note: The default implementation throws IllegalStateException.

      Throws:
      IllegalStateException - if this sink does not accept double values