Added equals and hashcode to JsonNull to ensure all instances of this class are the same.
This commit is contained in:
parent
ad1c1a731d
commit
3ff6bda2ad
|
@ -31,4 +31,20 @@ public final class JsonNull extends JsonElement {
|
||||||
protected void toString(StringBuilder sb) {
|
protected void toString(StringBuilder sb) {
|
||||||
sb.append("null");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user