Mercurial > dive4elements > river
changeset 6372:01073acf6735
Add hashCode and equals implementation to Range.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 19 Jun 2013 09:40:38 +0200 |
parents | 19459037b3c7 |
children | be283f9bc079 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java Wed Jun 19 15:03:05 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java Wed Jun 19 09:40:38 2013 +0200 @@ -69,5 +69,25 @@ public boolean inside(double x) { return x > start-EPSILON && x < end+EPSILON; } + + @Override + public int hashCode() { + return new Double(this.start).hashCode() ^ + new Double(this.end).hashCode(); + } + + @Override + public boolean equals(Object otherRange) { + if (otherRange == null) { + return false; + } + else if (otherRange instanceof Range) { + Range oRange = (Range) otherRange; + return + Math.abs(oRange.start - this.start) <= EPSILON + && Math.abs(oRange.end - this.end) <= EPSILON; + } + return false; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :