[Dive4elements-commits] [PATCH] Backend: Fixed constructor of ImportTimeInterval
Wald Commits
scm-commit at wald.intevation.org
Fri May 3 13:06:18 CEST 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1367579174 -7200
# Node ID 45871a108aaeb9dba33208973446497d8d524adb
# Parent 4110565baff8a3a33f176a80f9fd04ed2367ce51
Backend: Fixed constructor of ImportTimeInterval.
diff -r 4110565baff8 -r 45871a108aae backend/src/main/java/org/dive4elements/river/importer/ImportTimeInterval.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportTimeInterval.java Fri May 03 12:51:29 2013 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportTimeInterval.java Fri May 03 13:06:14 2013 +0200
@@ -31,29 +31,30 @@
}
public ImportTimeInterval(Date startTime) {
- this.startTime = startTime;
- this.stopTime = null;
+ this(startTime, null);
}
public ImportTimeInterval(Date startTime, Date stopTime) {
- Date start;
- Date stop;
- if (startTime == null) {
- start = stopTime;
- stop = null;
- }
- else {
- start = startTime;
- stop = stopTime;
- }
- if (stop != null && start.after(stop)) {
- this.stopTime = start;
- this.startTime = stop;
+ if (startTime != null && stopTime == null) {
+ this.startTime = startTime;
+ this.stopTime = null;
+ }
+ else if (startTime == null && stopTime != null) {
+ this.startTime = stopTime;
+ this.stopTime = null;
+ }
+ else if (startTime == null && stopTime == null) {
+ throw new IllegalArgumentException("Both dates are null.");
}
else {
- this.startTime = start;
- this.stopTime = stop;
+ if (startTime.after(stopTime)) {
+ Date t = startTime;
+ startTime = stopTime;
+ stopTime = t;
+ }
+ this.startTime = startTime;
+ this.stopTime = stopTime;
}
}
@@ -102,5 +103,10 @@
}
return peer;
}
+
+ @Override
+ public String toString() {
+ return "start time: " + startTime + ", stop time: " + stopTime;
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list