Skip to content

v0.2.47..v0.2.48 changeset Element.java

Garret Voltz edited this page Sep 27, 2019 · 1 revision
diff --git a/hoot-services/src/main/java/hoot/services/models/osm/Element.java b/hoot-services/src/main/java/hoot/services/models/osm/Element.java
index caf2948..177c8cb 100644
--- a/hoot-services/src/main/java/hoot/services/models/osm/Element.java
+++ b/hoot-services/src/main/java/hoot/services/models/osm/Element.java
@@ -22,7 +22,7 @@
  * This will properly maintain the copyright information. DigitalGlobe
  * copyrights will be updated automatically.
  *
- * @copyright Copyright (C) 2015, 2016, 2017 DigitalGlobe (http://www.digitalglobe.com/)
+ * @copyright Copyright (C) 2015, 2016, 2017, 2019 DigitalGlobe (http://www.digitalglobe.com/)
  */
 package hoot.services.models.osm;
 
@@ -34,6 +34,7 @@ import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -41,6 +42,7 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.reflect.MethodUtils;
@@ -646,6 +648,19 @@ public abstract class Element implements XmlSerializable, DbSerializable {
         return null;
     }
 
+    /**
+     * Returns the element types in sorted order
+     *
+     * @param Set<ElementType> types
+     *            a database relation member types to sort
+     * @return a list of element types
+     */
+    public static List<ElementType> elementTypesOrdered(Set<ElementType> types) {
+        return Arrays.asList( ElementType.Node, ElementType.Way, ElementType.Relation )
+                .stream().filter(type -> types.contains(type))
+                .collect(Collectors.toList());
+    }
+
     /*
      * Parses tags from the element XML and returns them in a map
      */
Clone this wiki locally