Class ErrorResponseBuilder

java.lang.Object
com.commercetools.api.models.error.ErrorResponseBuilder
All Implemented Interfaces:
Builder<ErrorResponse>

public class ErrorResponseBuilder extends Object implements Builder<ErrorResponse>
ErrorResponseBuilder
Example to create an instance using the builder pattern

     ErrorResponse errorResponse = ErrorResponse.builder()
             .statusCode(1)
             .message("{message}")
             .build()
 
  • Constructor Details

    • ErrorResponseBuilder

      public ErrorResponseBuilder()
  • Method Details

    • statusCode

      public ErrorResponseBuilder statusCode(Integer statusCode)

      HTTP status code corresponding to the error.

      Parameters:
      statusCode - value to be set
      Returns:
      Builder
    • message

      public ErrorResponseBuilder message(String message)

      First error message in the errors array.

      Parameters:
      message - value to be set
      Returns:
      Builder
    • errors

      public ErrorResponseBuilder errors(@Nullable ErrorObject... errors)

      Errors returned for a request.

      A single error response can contain multiple errors if the errors are related to the same HTTP status code such as 400.

      Parameters:
      errors - value to be set
      Returns:
      Builder
    • errors

      Errors returned for a request.

      A single error response can contain multiple errors if the errors are related to the same HTTP status code such as 400.

      Parameters:
      errors - value to be set
      Returns:
      Builder
    • plusErrors

      public ErrorResponseBuilder plusErrors(@Nullable ErrorObject... errors)

      Errors returned for a request.

      A single error response can contain multiple errors if the errors are related to the same HTTP status code such as 400.

      Parameters:
      errors - value to be set
      Returns:
      Builder
    • plusErrors

      public ErrorResponseBuilder plusErrors(Function<ErrorObjectBuilder,Builder<? extends ErrorObject>> builder)

      Errors returned for a request.

      A single error response can contain multiple errors if the errors are related to the same HTTP status code such as 400.

      Parameters:
      builder - function to build the errors value
      Returns:
      Builder
    • withErrors

      public ErrorResponseBuilder withErrors(Function<ErrorObjectBuilder,Builder<? extends ErrorObject>> builder)

      Errors returned for a request.

      A single error response can contain multiple errors if the errors are related to the same HTTP status code such as 400.

      Parameters:
      builder - function to build the errors value
      Returns:
      Builder
    • getStatusCode

      public Integer getStatusCode()

      HTTP status code corresponding to the error.

      Returns:
      statusCode
    • getMessage

      public String getMessage()

      First error message in the errors array.

      Returns:
      message
    • getErrors

      @Nullable public List<ErrorObject> getErrors()

      Errors returned for a request.

      A single error response can contain multiple errors if the errors are related to the same HTTP status code such as 400.

      Returns:
      errors
    • build

      public ErrorResponse build()
      builds ErrorResponse with checking for non-null required values
      Specified by:
      build in interface Builder<ErrorResponse>
      Returns:
      ErrorResponse
    • buildUnchecked

      public ErrorResponse buildUnchecked()
      builds ErrorResponse without checking for non-null required values
      Returns:
      ErrorResponse
    • of

      public static ErrorResponseBuilder of()
      factory method for an instance of ErrorResponseBuilder
      Returns:
      builder
    • of

      public static ErrorResponseBuilder of(ErrorResponse template)
      create builder for ErrorResponse instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder