Skip to content

Instantly share code, notes, and snippets.

@raykrueger
Created March 21, 2009 14:47
Show Gist options
  • Save raykrueger/82869 to your computer and use it in GitHub Desktop.
Save raykrueger/82869 to your computer and use it in GitHub Desktop.
public enum HttpStatus {
OK(200),
CREATED(201),
ACCEPTED(202),
NOT_MODIFIED(304),
BAD_REQUEST(400),
UNAUTHORIZED(401),
FORBIDDEN(403),
NOT_FOUND(404),
METHOD_NOT_ALLOWED(405),
NOT_ACCEPTABLE(406),
CONFLICT(409),
GONE(410),
LENGTH_REQUIRED(411),
PRECONDITION_FAILED(412),
REQUEST_ENTITY_TOO_LARGE(413),
REQUEST_URI_TOO_LONG(414),
UNSUPPORTED_MEDIA_TYPE(415),
REQUESTED_RANGE_NOT_SATISFIABLE(416),
EXPECTATION_FAILED(417);
private final int status;
HttpStatus(int statusCode) {
this.status = statusCode;
}
public int getStatus() {
return status;
}
public HttpStatus valueOf(int status) {
for (HttpStatus e : values()) {
if (e.getStatus() == status) {
return e;
}
}
throw new IllegalArgumentException("Unsupported status [" + status + "]");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment