diff options
author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-01-27 16:05:55 -0500 |
---|---|---|
committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-01-27 16:05:55 -0500 |
commit | a6a66e6fb11675e0ea738ad8d0b5a9ba7d2fac2b (patch) | |
tree | b45241f4c56a055148f4a15a47d2d6ff04fd382a /src/unitConverter/unit/BaseUnit.java | |
parent | ff30d9ab06bfc93012b90d24af57505b3d9c70d4 (diff) |
HOTFIX: Added equals and hashCode to the unit classes
Diffstat (limited to 'src/unitConverter/unit/BaseUnit.java')
-rwxr-xr-x | src/unitConverter/unit/BaseUnit.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/unitConverter/unit/BaseUnit.java b/src/unitConverter/unit/BaseUnit.java index d4a1e9c..fe36c45 100755 --- a/src/unitConverter/unit/BaseUnit.java +++ b/src/unitConverter/unit/BaseUnit.java @@ -108,6 +108,24 @@ public final class BaseUnit extends AbstractUnit { return new LinearUnit(this, 1 / divisor); } + @Override + public boolean equals(final Object obj) { + if (!(obj instanceof BaseUnit)) + return false; + final BaseUnit other = (BaseUnit) obj; + return Objects.equals(this.getSystem(), other.getSystem()) + && Objects.equals(this.getDimension(), other.getDimension()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = result * prime + this.getSystem().hashCode(); + result = result * prime + this.getDimension().hashCode(); + return result; + } + /** * Multiplies this unit by another unit. * |