Fixed augment schema path resolving.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / yang-model-parser-impl / src / main / java / org / opendaylight / controller / yang / model / parser / builder / impl / AugmentationSchemaBuilderImpl.java
index e7d389fc4eece95cb9b8de5e1fe5113c16914179..c27bf683fc3b5557c6875b6747e4ff37df784367 100644 (file)
@@ -31,23 +31,31 @@ import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
 import org.opendaylight.controller.yang.model.util.RevisionAwareXPathImpl;
 
 public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
-
     private final AugmentationSchemaImpl instance;
+    private final int line;
     private final String augmentTargetStr;
-    private final SchemaPath augmentTarget;
+    private SchemaPath augmentTarget;
+    private SchemaPath finalAugmentTarget;
     private String whenCondition;
     private final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();
     private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
     private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
+    private boolean resolved;
 
-    AugmentationSchemaBuilderImpl(final String augmentTargetStr) {
+    AugmentationSchemaBuilderImpl(final String augmentTargetStr, final int line) {
         this.augmentTargetStr = augmentTargetStr;
+        this.line = line;
         final SchemaPath targetPath = YangModelBuilderUtil
                 .parseAugmentPath(augmentTargetStr);
         augmentTarget = targetPath;
         instance = new AugmentationSchemaImpl(targetPath);
     }
 
+    @Override
+    public int getLine() {
+        return line;
+    }
+
     @Override
     public void addChildNode(DataSchemaNodeBuilder childNode) {
         childNodes.add(childNode);
@@ -78,6 +86,8 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
 
     @Override
     public AugmentationSchema build() {
+        instance.setTargetPath(finalAugmentTarget);
+
         RevisionAwareXPath whenStmt;
         if (whenCondition == null) {
             whenStmt = null;
@@ -110,6 +120,16 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
         return instance;
     }
 
+    @Override
+    public boolean isResolved() {
+        return resolved;
+    }
+
+    @Override
+    public void setResolved(boolean resolved) {
+        this.resolved = resolved;
+    }
+
     public String getWhenCondition() {
         return whenCondition;
     }
@@ -144,6 +164,11 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
         return augmentTarget;
     }
 
+    @Override
+    public void setTargetPath(SchemaPath path) {
+        this.finalAugmentTarget = path;
+    }
+
     @Override
     public String getTargetPathAsString() {
         return augmentTargetStr;
@@ -217,7 +242,7 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
 
 
     private static class AugmentationSchemaImpl implements AugmentationSchema {
-        private final SchemaPath targetPath;
+        private SchemaPath targetPath;
         private RevisionAwareXPath whenCondition;
         private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
         private Set<GroupingDefinition> groupings = Collections.emptySet();
@@ -236,6 +261,10 @@ public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder
             return targetPath;
         }
 
+        private void setTargetPath(SchemaPath path) {
+            this.targetPath = path;
+        }
+
         @Override
         public RevisionAwareXPath getWhenCondition() {
             return whenCondition;