public static final class Response.Status
extends java.lang.Object
Developers note: the first urge we have is to wrap all the codes and the messages as enums. While noble, this does not work well, as message can be changed; and user may use more status codes that we provide. Enums would not work; so naturally we would head forward to use the class to wrap the status code and the message. This would work. However, that introduces level of complexity that is not necessary. For example, if response returns instance of such Status class, we would need to use equals() to check against the real values. If we dont expose the status class, then we dont have to use, hence we are back to the beginning :)
We could use also a Map for getting default value, but a switch should produce more optimized bytecode. Since we do not change this part of code much, it make sense to have it like this.
| Modifier and Type | Field and Description |
|---|---|
static int |
ACCEPTED |
static int |
BAD_GATEWAY |
static int |
BAD_REQUEST |
static int |
CONFLICT |
static int |
CREATED |
static int |
FORBIDDEN |
static int |
FOUND |
static int |
GATEWAY_TIMEOUT |
static int |
GONE |
static int |
INTERNAL_SERVER_ERROR |
static int |
METHOD_NOT_ALLOWED |
static int |
MOVED_PERMANENTLY |
static int |
MULTIPLE_CHOICES |
static int |
NO_CONTENT |
static int |
NON_AUTHORITATIVE_INFORMATION |
static int |
NOT_ACCEPTABLE |
static int |
NOT_FOUND |
static int |
NOT_IMPLEMENTED |
static int |
NOT_MODIFIED |
static int |
OK |
static int |
PARTIAL_CONTENT |
static int |
PROXY_AUTHENTICATION_REQUIRED |
static int |
REQUEST_TIMEOUT |
static int |
RESET_CONTENT |
static int |
SEE_OTHER |
static int |
SERVICE_UNAVAILABLE |
static int |
TEMPORARY_REDIRECT |
static int |
UNAUTHORIZED |
static int |
USE_PROXY |
| Modifier | Constructor and Description |
|---|---|
protected |
Status() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
defaultMessage(int statusCode)
Returns default message for given status.
|
static boolean |
succeeded(int statusCode)
Checks if response succeeded.
|
public static final int ACCEPTED
public static final int BAD_GATEWAY
public static final int BAD_REQUEST
public static final int CONFLICT
public static final int CREATED
public static final int FORBIDDEN
public static final int FOUND
public static final int GATEWAY_TIMEOUT
public static final int GONE
public static final int INTERNAL_SERVER_ERROR
public static final int METHOD_NOT_ALLOWED
public static final int MOVED_PERMANENTLY
public static final int MULTIPLE_CHOICES
public static final int NO_CONTENT
public static final int NON_AUTHORITATIVE_INFORMATION
public static final int NOT_ACCEPTABLE
public static final int NOT_FOUND
public static final int NOT_IMPLEMENTED
public static final int NOT_MODIFIED
public static final int OK
public static final int PARTIAL_CONTENT
public static final int PROXY_AUTHENTICATION_REQUIRED
public static final int REQUEST_TIMEOUT
public static final int RESET_CONTENT
public static final int SEE_OTHER
public static final int SERVICE_UNAVAILABLE
public static final int TEMPORARY_REDIRECT
public static final int UNAUTHORIZED
public static final int USE_PROXY