DOMDataTreeIdentifier implements Immutable, Path<DOMDataTreeIdentifier>, Serializable,
        Comparable<DOMDataTreeIdentifier> { @Override public int compareTo(final DOMDataTreeIdentifier domDataTreeIdentifier) { int cmp = datastoreType.compareTo(domDataTreeIdentifier.datastoreType); if (cmp != 0) { return cmp; } final Iterator<PathArgument> myIter = rootIdentifier.getPathArguments().iterator(); final Iterator<PathArgument> otherIter = domDataTreeIdentifier.rootIdentifier.getPathArguments().iterator(); while (myIter.hasNext()) { if (!otherIter.hasNext()) { return 1; } final PathArgument myPathArg = myIter.next(); final PathArgument otherPathArg = otherIter.next(); cmp = myPathArg.compareTo(otherPathArg); if (cmp != 0) { return cmp; } } return otherIter.hasNext() ? -1 : 0; } DOMDataTreeIdentifier(final LogicalDatastoreType datastoreType,
            final YangInstanceIdentifier rootIdentifier); LogicalDatastoreType getDatastoreType(); YangInstanceIdentifier getRootIdentifier(); @Override boolean contains(final DOMDataTreeIdentifier other); DOMDataTreeIdentifier toOptimized(); @Override int hashCode(); @Override boolean equals(final @Nullable Object obj); @Override int compareTo(final DOMDataTreeIdentifier domDataTreeIdentifier); @Override String toString();  }
@Test public void compareToTest() { final YangInstanceIdentifier compareFirstIid = YangInstanceIdentifier.create( new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, COMPARE_FIRST_LISTS))); final YangInstanceIdentifier compareSecondIid = YangInstanceIdentifier.create( new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, COMPARE_SECOND_LISTS))); assertEquals("Compare same to same", REF_TREE.compareTo( new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, REF_YII_IID)), 0); assertNotEquals("Compare same to same with different datastore", REF_TREE.compareTo(new DOMDataTreeIdentifier( LogicalDatastoreType.CONFIGURATION, REF_YII_IID)), 0); assertEquals("Compare same to same with different datastore", new DOMDataTreeIdentifier( LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.create( YangInstanceIdentifier.NodeIdentifier.create(QName.create(TEST_MODULE, REF_LISTS)), YangInstanceIdentifier.NodeIdentifier.create(QName.create(TEST_MODULE, TEST_LISTS)))) .compareTo(REF_TREE), 1); assertTrue("Compare first to second", new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, compareFirstIid).compareTo(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, compareSecondIid)) < 0); assertTrue("Compare second to first", new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, compareSecondIid).compareTo(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, compareFirstIid)) > 0); }