changeset 6380:dc23ffb9d82c

Range: Add start and end setters, doc, clone function.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 21 Jun 2013 11:34:22 +0200
parents 9d5f09698d81
children df1a3826c691
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java	Fri Jun 21 10:20:28 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java	Fri Jun 21 11:34:22 2013 +0200
@@ -31,10 +31,19 @@
         this.end   = end;
     }
 
+    public void setStart(double start) {
+        this.start = start;
+    }
+
     public double getStart() {
         return start;
     }
 
+
+    public void setEnd(double end) {
+        this.end = end;
+    }
+
     public double getEnd() {
         return end;
     }
@@ -70,12 +79,22 @@
         return x > start-EPSILON && x < end+EPSILON;
     }
 
+    public boolean contains(double x) {
+        return inside(x);
+    }
+
+
+    /** Hash Code. */
     @Override
     public int hashCode() {
         return new Double(this.start).hashCode() ^
                new Double(this.end).hashCode();
     }
 
+
+    /**
+     * Compares start and end values with some epsilon.
+     */
     @Override
     public boolean equals(Object otherRange) {
         if (otherRange instanceof Range) {
@@ -86,5 +105,11 @@
         }
         return false;
     }
+
+    /** Returns clone with same start and end values. */
+    @Override
+    public Object clone() {
+        return new Range(this.start, this.end);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org