Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/importer/ImportRange.java @ 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 | 3d83a4cf33ba |
children | 4b26fd60105f |
comparison
equal
deleted
inserted
replaced
7194:5358a5497b2b | 7221:70ab9e8cdefb |
---|---|
47 else if (a == b) { | 47 else if (a == b) { |
48 this.a = a; | 48 this.a = a; |
49 this.b = null; | 49 this.b = null; |
50 } | 50 } |
51 else { | 51 else { |
52 if (a.compareTo(b) == 1) { | 52 if (a.compareTo(b) > 0) { |
53 BigDecimal t = a; a = b; b = t; | 53 BigDecimal t = a; a = b; b = t; |
54 } | 54 } |
55 this.a = a; | 55 this.a = a; |
56 this.b = b; | 56 this.b = b; |
57 } | 57 } |
79 public BigDecimal getA() { | 79 public BigDecimal getA() { |
80 return a; | 80 return a; |
81 } | 81 } |
82 | 82 |
83 public void setA(BigDecimal a) { | 83 public void setA(BigDecimal a) { |
84 this.a = a; | 84 if (this.b != null && a.compareTo(b) >= 0) { |
85 throw new IllegalArgumentException("a (" + a + ") must be smaller than b (" + b + ")."); | |
86 } | |
87 else { | |
88 this.a = a; | |
89 } | |
85 } | 90 } |
86 | 91 |
87 public BigDecimal getB() { | 92 public BigDecimal getB() { |
88 return b; | 93 return b; |
89 } | 94 } |
90 | 95 |
91 public void setB(BigDecimal b) { | 96 public void setB(BigDecimal b) { |
92 this.b = b; | 97 if (b != null && b.compareTo(a) <= 0) { |
98 throw new IllegalArgumentException("b (" + b + ") must be greater than a (" + a + ") or null."); | |
99 } | |
100 else { | |
101 this.b = b; | |
102 } | |
93 } | 103 } |
94 | 104 |
95 public Range getPeer(River river) { | 105 public Range getPeer(River river) { |
96 if (peer == null) { | 106 if (peer == null) { |
97 peer = ImporterSession.getInstance().getRange(river, a, b); | 107 peer = ImporterSession.getInstance().getRange(river, a, b); |