Bug 4412: New yang parser effective statements cleanup
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / CaseShorthandImpl.java
index e5aec1f44775a5e2424222d3e5ccd867eab7a5e7..ce54d65427ca47f3ccf9521e09e5a714ed4d4129 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;
@@ -35,30 +35,18 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
     private final DataSchemaNode caseShorthandNode;
     private final QName qName;
     private final SchemaPath path;
-
     private final String description;
     private final String reference;
     private final Status status;
-
     private final boolean augmenting;
     private final boolean addedByUses;
     private final ConstraintDefinition constraints;
-    private ChoiceCaseNode original;
-
-    ImmutableList<UnknownSchemaNode> unknownNodes;
+    private final List<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();
@@ -164,7 +152,7 @@ public class CaseShorthandImpl implements ChoiceCaseNode, DerivableSchemaNode {
 
     @Override
     public Optional<? extends SchemaNode> getOriginal() {
-        return Optional.fromNullable(original);
+        return Optional.absent();
     }
 
     @Override