Added support for root in create(TreeType, YangInstanceIdentifier)
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / InMemoryDataTreeFactory.java
index 556a8c3468eec9af2c57c8d9f24898e97f847f43..a60497fd448117d9e14a4f9652062b8fd85a5f36 100644 (file)
@@ -47,6 +47,9 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
 
     @Override
     public TipProducingDataTree create(final TreeType treeType, final YangInstanceIdentifier rootPath) {
+        if (rootPath.isEmpty()) {
+            return create(treeType);
+        }
         final NormalizedNode<?, ?> root;
         final PathArgument arg = rootPath.getLastPathArgument();
         if (arg instanceof NodeIdentifier) {
@@ -56,6 +59,7 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
             b.withNodeIdentifier((NodeIdentifierWithPredicates) arg);
             root = b.build();
         } else {
+
             // FIXME: implement augmentations and leaf-lists
             throw new IllegalArgumentException("Unsupported root node " + arg);
         }