Use SchemaPath.getParent() 22/27522/1
authorRobert Varga <rovarga@cisco.com>
Mon, 28 Sep 2015 08:39:06 +0000 (10:39 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 28 Sep 2015 08:39:06 +0000 (10:39 +0200)
Creating a parent SchemaPath is simple, no need to fork them.

Change-Id: I6c93e6a913fa582f8cd615deb992738f22afe0e0
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/CaseShorthandImpl.java

index e5aec1f44775a5e2424222d3e5ccd867eab7a5e7..f72fc22b01188506b64ec95368dfcc90c84ec87d 100644 (file)
@@ -8,8 +8,8 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -43,22 +43,13 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
     private final boolean augmenting;
     private final boolean addedByUses;
     private final ConstraintDefinition constraints;
+    private final List<UnknownSchemaNode> unknownNodes;
     private ChoiceCaseNode original;
 
-    ImmutableList<UnknownSchemaNode> unknownNodes;
-
     public CaseShorthandImpl(final DataSchemaNode caseShorthandNode) {
         this.caseShorthandNode = caseShorthandNode;
         this.qName = caseShorthandNode.getQName();
-
-        SchemaPath caseShorthandNodePath = caseShorthandNode.getPath();
-        Iterable<QName> pathFromRoot = caseShorthandNodePath.getPathFromRoot();
-        // FIXME: cacheShorthandNodePath.getParent() should be enough
-        this.path = SchemaPath
-                .create(Iterables.limit(pathFromRoot,
-                        Iterables.size(pathFromRoot) - 1),
-                        caseShorthandNodePath.isAbsolute());
-
+        this.path = Preconditions.checkNotNull(caseShorthandNode.getPath().getParent());
         this.description = caseShorthandNode.getDescription();
         this.reference = caseShorthandNode.getReference();
         this.status = caseShorthandNode.getStatus();