Implementing hashcode and equals for JsonPrimitives as value type equality.
This commit is contained in:
parent
f9b1225581
commit
f418ab69a2
@ -330,4 +330,21 @@ public final class JsonPrimitive extends JsonElement {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (value == null) ? 31 : value.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null) return false;
|
||||
if (getClass() != obj.getClass()) return false;
|
||||
JsonPrimitive other = (JsonPrimitive)obj;
|
||||
if (value == null) {
|
||||
if (other.value != null) return false;
|
||||
} else if (!value.equals(other.value)) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user