Class Command.Builder<T>

java.lang.Object
eu.mihosoft.devcom.Command.Builder<T>
Type Parameters:
T -
Enclosing class:
Command<T>

public static final class Command.Builder<T> extends Object
Command builder.
  • Method Details

    • withData

      public Command.Builder<T> withData(T data)
      Parameters:
      data - data to be sent by the command
      Returns:
      this builder
    • withOnSent

      public Command.Builder<T> withOnSent(Consumer<T> onSent)
      Parameters:
      onSent - called if/when the data has been sent (may be null).
      Returns:
      this builder
    • withOnReceived

      public Command.Builder<T> withOnReceived(Consumer<T> onReceived)
      Parameters:
      onReceived - called if/when the data has been received (may be null).
      Returns:
      this builder
    • withReplyExpected

      public Command.Builder<T> withReplyExpected(boolean replyExpected)
      Parameters:
      replyExpected - defines whether a reply is expected.
      Returns:
      this builder
    • withOnError

      public Command.Builder<T> withOnError(BiConsumer<T,Exception> onError)
      Parameters:
      onError - error handler is called whenever an error occurs (may be null).
      Returns:
      this builder
    • withOnCancellationRequested

      public Command.Builder<T> withOnCancellationRequested(Consumer<String> onCancellationRequested)
      Parameters:
      onCancellationRequested - handler is called if cancellation is requested (may be null).
      Returns:
      this builder
    • build

      public Command<T> build()
      Creates a new command.
      Returns:
      new command