Class ResponseEnvelope<T>
java.lang.Object
com.tccc.kos.commons.util.dispatcher.ResponseEnvelope<T>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetData()
Retrieves the response's data object.getError()
Retrieves the error message.int
Retrieves the HTTP status.Retrieves theResponseVersion
object.void
Sets the response's data object.void
Sets the error message.void
setStatus
(int status) Sets the HTTP statusvoid
setVersion
(ResponseVersion version) Sets theResponseVersion
object.boolean
success()
Return true if the request succeeded.toString()
Returns the string representation of this object.
-
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
Retrieves theResponseVersion
object.- Returns:
- the response version object
-
setVersion
Sets theResponseVersion
object.- Parameters:
version
- the response version object
-
getData
Retrieves the response's data object.- Returns:
- the response's data object
-
setData
Sets the response's data object.- Parameters:
data
- the response's data object
-
getError
Retrieves the error message.- Returns:
- the error message, or
null
if no error
-
setError
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
Returns the string representation of this object.
-