BUG-1069: made InstanceIdentifier.PathArgument implement Comparable.
[mdsal.git] / yang / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / InstanceIdentifier.java
index 1ff28fbeeafe67d7503a6114db503dde245094e1..b135a86234bdf8136f393cd7eb5b62f4e48e23ee 100644 (file)
@@ -7,20 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.binding;
 
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
-
 import com.google.common.base.Objects;
 import com.google.common.base.Objects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.Path;
 
 /**
  *
@@ -492,7 +490,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
      * Interface which implementations are used as path components of the
      * path in overall data tree.
      */
-    public interface PathArgument {
+    public interface PathArgument extends Comparable<PathArgument> {
         Class<? extends DataObject> getType();
     }
 
@@ -527,6 +525,11 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
             final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
             return type.equals(other.type);
         }
+
+        @Override
+        public int compareTo(PathArgument arg) {
+            return type.getCanonicalName().compareTo(arg.getType().getCanonicalName());
+        }
     }
 
     /**