changeset 7463:52c364813cb1

Code cleanup.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 30 Oct 2013 11:56:13 +0100
parents 906ed0b1f3f1
children f16dce7a2407
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java
diffstat 1 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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);
         }
     }
 

http://dive4elements.wald.intevation.org