ref #9701 method to find the highest type status in a TypeDesignationWorkingSet
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Thu, 9 Sep 2021 08:38:41 +0000 (10:38 +0200)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Thu, 9 Sep 2021 08:38:41 +0000 (10:38 +0200)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/name/TypeDesignationWorkingSet.java

index 4b2b105f9b4843be0b2ca892f9bec34be81403f6..2828f11b00dfac511396d07f604a44712a3fd809 100644 (file)
@@ -10,6 +10,7 @@ package eu.etaxonomy.cdm.api.service.name;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Comparator;
 import java.util.LinkedHashMap;
 import java.util.List;
 
@@ -135,4 +136,17 @@ public class TypeDesignationWorkingSet
             return super.toString();
         }
     }
+
+    /**
+     * Uses the <code>comparator</code> to find the highest {@link TypeDesignationStatusBase} term and returns that.
+     */
+    public TypeDesignationStatusBase<?> highestTypeStatus(Comparator<TypeDesignationStatusBase<?>> comparator) {
+        TypeDesignationStatusBase<?> highestTypeStatus = null;
+        for(TypeDesignationStatusBase<?> status : keySet()) {
+            if(comparator.compare(status, highestTypeStatus) < 0){
+                highestTypeStatus = status;
+            }
+        }
+        return highestTypeStatus;
+    }
 }
\ No newline at end of file