Added equals and hashcode to JsonNull to ensure all instances of this class are the same.

This commit is contained in:
Inderjeet Singh 2008-11-14 22:33:39 +00:00
parent ad1c1a731d
commit 3ff6bda2ad

View File

@ -31,4 +31,20 @@ public final class JsonNull extends JsonElement {
protected void toString(StringBuilder sb) {
sb.append("null");
}
/**
* All instances of JsonNull have the same hash code since they are indistinguishable
*/
@Override
public int hashCode() {
return JsonNull.class.hashCode();
}
/**
* All instances of JsonNull are the same
*/
@Override
public boolean equals(Object other) {
return other instanceof JsonNull;
}
}