Class ResponseEnvelope<T>

java.lang.Object
com.tccc.kos.commons.util.dispatcher.ResponseEnvelope<T>

public class ResponseEnvelope<T> extends Object
Data class that encapsulates the response from an HTTP/REST endpoint. You will probably never create one of these objects manually. Instead, they are returned from a variety of API calls.

Data Fields

 
  private int status;               // the HttpStatus code
  private ResponseVersion version;  // the handler's version that provided the response
  private T data;                   // the data received from the handler
  private String error;             // the error message, or null when no error
 
 
Since:
1.0
Version:
2022-08-30
See Also:
  • Constructor Details

    • ResponseEnvelope

      public ResponseEnvelope()
  • Method Details

    • getStatus

      public int getStatus()
      Retrieves the HTTP status.
      Returns:
      the HTTP status
    • setStatus

      public void setStatus(int status)
      Sets the HTTP status
      Parameters:
      status - the HTTP status to set
    • getVersion

      public ResponseVersion getVersion()
      Retrieves the ResponseVersion object.
      Returns:
      the response version object
    • setVersion

      public void setVersion(ResponseVersion version)
      Sets the ResponseVersion object.
      Parameters:
      version - the response version object
    • getData

      public T getData()
      Retrieves the response's data object.
      Returns:
      the response's data object
    • setData

      public void setData(T data)
      Sets the response's data object.
      Parameters:
      data - the response's data object
    • getError

      public String getError()
      Retrieves the error message.
      Returns:
      the error message, or null if no error
    • setError

      public void setError(String error)
      Sets the error message.
      Parameters:
      error - the error message to set
    • success

      public boolean success()
      Return true if the request succeeded. This is true if the status is 200 AND if there is no error.
    • toString

      public String toString()
      Returns the string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      string representation of this object