changeset 7221:70ab9e8cdefb double-precision

Range importer: Do not allow to set invalid a or b.
author Tom Gottfried <tom@intevation.de>
date Tue, 01 Oct 2013 18:32:01 +0200
parents 5358a5497b2b
children c5214e04b9b8
files backend/src/main/java/org/dive4elements/river/importer/ImportRange.java
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRange.java	Fri Sep 27 17:45:18 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRange.java	Tue Oct 01 18:32:01 2013 +0200
@@ -49,7 +49,7 @@
             this.b = null;
         }
         else {
-            if (a.compareTo(b) == 1) {
+            if (a.compareTo(b) > 0) {
 		BigDecimal t = a; a = b; b = t;
             }
             this.a = a;
@@ -81,7 +81,12 @@
     }
 
     public void setA(BigDecimal a) {
-        this.a = a;
+        if (this.b != null && a.compareTo(b) >= 0) {
+            throw new IllegalArgumentException("a (" + a + ") must be smaller than b (" + b + ").");
+        }
+        else {
+            this.a = a;
+        }
     }
 
     public BigDecimal getB() {
@@ -89,7 +94,12 @@
     }
 
     public void setB(BigDecimal b) {
-        this.b = b;
+        if (b != null && b.compareTo(a) <= 0) {
+            throw new IllegalArgumentException("b (" + b + ") must be greater than a (" + a + ") or null.");
+        }
+        else {
+            this.b = b;
+        }
     }
 
     public Range getPeer(River river) {

http://dive4elements.wald.intevation.org