[PATCH 1 of 2] (issue1596) Make MiddleBedHeightData comparable

Wald Commits scm-commit at wald.intevation.org
Mon Dec 16 12:26:57 CET 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1387192981 -3600
# Node ID 4508501cdde711658886f9bc1f50943104336d76
# Parent  fa4fbd66e75206d9151537312aeab06d1e103012
(issue1596) Make MiddleBedHeightData comparable

diff -r fa4fbd66e752 -r 4508501cdde7 artifacts/src/main/java/org/dive4elements/river/artifacts/model/MiddleBedHeightData.java
--- 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 :


More information about the Dive4elements-commits mailing list