changeset 7692:4508501cdde7

(issue1596) Make MiddleBedHeightData comparable
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 16 Dec 2013 12:23:01 +0100
parents fa4fbd66e752
children c130196389df
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java
diffstat 1 files changed, 28 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java	Fri Dec 13 19:03:00 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java	Mon Dec 16 12:23:01 2013 +0100
@@ -21,7 +21,8 @@
 import org.apache.log4j.Logger;
 
 
-public class MiddleBedHeightData implements Serializable {
+public class MiddleBedHeightData implements Serializable,
+                                            Comparable<MiddleBedHeightData> {
 
     /** Very private logger. */
     private static final Logger logger = Logger.getLogger(MiddleBedHeightData.class);
@@ -189,5 +190,31 @@
             );
         }
     }
+
+     public int compareTo(MiddleBedHeightData other) {
+
+         int descCompared = description.compareTo(other.getDescription());
+
+         if (descCompared != 0) {
+             return descCompared;
+         }
+
+         if (size() == 0 || other.size() == 0) {
+             if (size() == 0 && other.size() > 0) {
+                 return 1;
+             } else if (size() > 0 && other.size() == 0) {
+                 return -1;
+             } else if (size() == 0 && other.size() == 0) {
+                return 0;
+             }
+         }
+
+         if (getKM(0) < other.getKM(0)) {
+             return -1;
+         } else if (getKM(0) > other.getKM(0)) {
+             return 1;
+         }
+         return 0;
+     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org