[PATCH 2 of 5] Code cleanup
Wald Commits
scm-commit at wald.intevation.org
Wed Oct 30 11:59:18 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1383130573 -3600
# Node ID 52c364813cb155205475fd8acbcedecfe94f8b68
# Parent 906ed0b1f3f116f7611f9284c8ca4a0f2ed8bca9
Code cleanup.
diff -r 906ed0b1f3f1 -r 52c364813cb1 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Wed Oct 30 11:55:10 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Wed Oct 30 11:56:13 2013 +0100
@@ -77,20 +77,26 @@
}
public void addDensity(double km, double density, int year) {
+
logger.debug("adding " + year);
- if (this.densities.containsKey(year)) {
- List<SedimentDensityValue> list = this.densities.get(year);
- list.add(new SedimentDensityValue(km, density, year));
+
+ Integer key = Integer.valueOf(year);
+
+ List<SedimentDensityValue> list = densities.get(key);
+
+ if (list == null) {
+ list = new ArrayList<SedimentDensityValue>();
+ densities.put(key, list);
}
- else {
- List<SedimentDensityValue> list =
- new ArrayList<SedimentDensityValue>();
- list.add(new SedimentDensityValue(km, density, year));
- densities.put(year, list);
- }
- if (!this.years.contains(new Integer(year))) {
+
+ list.add(new SedimentDensityValue(km, density, year));
+
+ // XXX: Why do we store a redundant list of years, too?
+ // Years are the keys of densities so they can be easily
+ // accessed by their key set!
+ if (!years.contains(key)) {
logger.debug("new year");
- years.add(new Integer(year));
+ years.add(key);
}
}
More information about the Dive4elements-commits
mailing list