Implemented hashCode, compareTo, equals, and toString for HttpResponseStatus
This commit is contained in:
parent
94544193bd
commit
3235c154a3
@ -32,7 +32,7 @@ package org.jboss.netty.handler.codec.http;
|
|||||||
*
|
*
|
||||||
* @apiviz.exclude
|
* @apiviz.exclude
|
||||||
*/
|
*/
|
||||||
public class HttpResponseStatus {
|
public class HttpResponseStatus implements Comparable<HttpResponseStatus> {
|
||||||
|
|
||||||
public static final HttpResponseStatus CONTINUE = new HttpResponseStatus(100, "Continue");
|
public static final HttpResponseStatus CONTINUE = new HttpResponseStatus(100, "Continue");
|
||||||
|
|
||||||
@ -131,4 +131,31 @@ public class HttpResponseStatus {
|
|||||||
public String getReasonPhrase() {
|
public String getReasonPhrase() {
|
||||||
return reasonPhrase;
|
return reasonPhrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (!(o instanceof HttpResponseStatus)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return getCode() == ((HttpResponseStatus) o).getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(HttpResponseStatus o) {
|
||||||
|
return getCode() - o.getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder buf = new StringBuilder(reasonPhrase + 5);
|
||||||
|
buf.append(code);
|
||||||
|
buf.append(' ');
|
||||||
|
buf.append(reasonPhrase);
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user