Interface HttpOperation<T>

Type Parameters:
T - type of object a success response is represented as

public interface HttpOperation<T>
A sequence of instructions that can be chained together, building up a final operation which can be executed with execute().

Specifying a success-handler via the onSuccess(Consumer) method is optional.

Specifying an error-handling strategy is also optional, but any error represented by HttpOperationErrorType would throw a RollbackException. You can specify error-handling via the onError(Consumer) method.

To ignore errors, use ignoreError().

  • Method Details

    • onSuccess

      HttpOperation<T> onSuccess(Consumer<HttpResponse<T>> successHandler)
      A function called when HTTP request execution has completed successfully with an HTTP response status code of 200.
      Parameters:
      successHandler - function to call during execution
      Returns:
      this HTTP operation
    • onError

      HttpOperation<T> onError(Consumer<HttpOperationError> errorHandler)
      A function called when an HTTP request execution has failed with one of the HttpOperationErrorType errors.

      If neither this function nor ignoreError() is specified, then RollbackException is thrown on error.

      Parameters:
      errorHandler - function to call during execution
      Returns:
      this HTTP operation
    • ignoreError

      HttpOperation<T> ignoreError()
      When specified, any error specified by HttpOperationErrorType is ignored during HTTP request execution.
      Returns:
      this http operation
    • execute

      void execute()
      Executes the HTTP operation.