Class ErrorResponseBuilder

java.lang.Object
za.co.wethinkcode.robots.server.serverResponse.ResponseBuilder
za.co.wethinkcode.robots.server.errors.ErrorResponseBuilder

public class ErrorResponseBuilder extends ResponseBuilder
Builder pattern class for creating error responses
  • Field Details

  • Constructor Details

    • ErrorResponseBuilder

      public ErrorResponseBuilder()
      Empty constructor for the error response builder
    • ErrorResponseBuilder

      public ErrorResponseBuilder(ClientCommandResult result)
      Constructor the build a builder directly from a Client Command result
      Parameters:
      result - the failed client command's result
  • Method Details

    • setInternalResponseCode

      public ErrorResponseBuilder setInternalResponseCode(InternalResponseCode internalResponseCode)
      Setter for the internal response code
      Parameters:
      internalResponseCode - which InternalResponseCode it uses
      Returns:
      the builder
    • setState

      public ErrorResponseBuilder setState(RobotState state)
      Setter for the State of the robot
      Parameters:
      state - the robot state in the error
      Returns:
      the builder
    • setMessage

      public ErrorResponseBuilder setMessage(String message)
      Setter for the message
      Overrides:
      setMessage in class ResponseBuilder
      Parameters:
      message - the message of this server response
      Returns:
      the error response builder
    • addData

      public ErrorResponseBuilder addData(Map<String,String> data)
      Setter for the data of this error response builder
      Parameters:
      data - the data of the error
      Returns:
      the builder
    • addErrorSource

      public ErrorResponseBuilder addErrorSource(ImplementedClientCommands errorSource)
      Setter for the error source of this error response
      Parameters:
      errorSource - which command caused the error
      Returns:
      the builder
    • build

      public ServerResponse build(InternalResponseCode internalResponseCode)
      Quick builder to build based a ServerResponse based on an InternalResponseCode
      Parameters:
      internalResponseCode - the internal response code
      Returns:
      a new custom ServerResponse object.
    • build

      public ServerResponse build()
      Build in place the server response from this error
      Overrides:
      build in class ResponseBuilder
      Returns:
      a Server Response based on this error