Implemented hashCode, compareTo, equals, and toString for HttpResponseStatus

This commit is contained in:
Trustin Lee 2009-03-10 07:56:53 +00:00
parent 94544193bd
commit 3235c154a3

View File

@ -32,7 +32,7 @@ package org.jboss.netty.handler.codec.http;
*
* @apiviz.exclude
*/
public class HttpResponseStatus {
public class HttpResponseStatus implements Comparable<HttpResponseStatus> {
public static final HttpResponseStatus CONTINUE = new HttpResponseStatus(100, "Continue");
@ -131,4 +131,31 @@ public class HttpResponseStatus {
public String getReasonPhrase() {
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();
}
}