[Dive4elements-commits] [PATCH 1 of 4] Range: Add start and end setters, doc, clone function

Wald Commits scm-commit at wald.intevation.org
Fri Jun 21 11:45:57 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1371807262 -7200
# Node ID dc23ffb9d82ccd81fe0ec40eedad368cffe93e29
# Parent  9d5f09698d818e209c567193bc0f515cc3fdff5d
Range: Add start and end setters, doc, clone function.

diff -r 9d5f09698d81 -r dc23ffb9d82c artifacts/src/main/java/org/dive4elements/river/artifacts/model/Range.java
--- 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 :


More information about the Dive4elements-commits mailing list