# HG changeset patch # User Tom Gottfried # Date 1380645121 -7200 # Node ID 70ab9e8cdefb70af31e6d1c0c3cc616ed98f48ab # Parent 5358a5497b2b553ff11fb243469a07323494bad8 Range importer: Do not allow to set invalid a or b. diff -r 5358a5497b2b -r 70ab9e8cdefb backend/src/main/java/org/dive4elements/river/importer/ImportRange.java --- 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) {