Correct QName.compareTo()
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / QName.java
index 2c19fa9f0295263ad9a6f85f7eed1a7c7ce47e80..60072a1b5955967a49c2106e38eea812802ca7e1 100644 (file)
@@ -371,17 +371,11 @@ public final class QName extends AbstractQName implements Comparable<QName> {
         return getLocalName().equals(other.getLocalName()) && Objects.equals(getNamespace(), other.getNamespace());
     }
 
-    // FIXME: this comparison function looks odd. We are sorting first by local name and then by module? What is
-    //        the impact on iteration order of SortedMap<QName, ?>?
     @Override
     @SuppressWarnings("checkstyle:parameterName")
     public int compareTo(final QName o) {
-        // compare mandatory localName parameter
-        int result = getLocalName().compareTo(o.getLocalName());
-        if (result != 0) {
-            return result;
-        }
-        return module.compareTo(o.module);
+        final int result = module.compareTo(o.module);
+        return result != 0 ? result : getLocalName().compareTo(o.getLocalName());
     }
 
     @Override