Refactored parsing of uses and augment statements.
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / impl / ChoiceBuilder.java
index 65208431c0ed374ce348337667cf0466a8ad09a7..7ec499534c39ced368a5006809292a90f37381c3 100644 (file)
@@ -53,26 +53,6 @@ public final class ChoiceBuilder extends AbstractSchemaNodeBuilder implements Da
         constraints = new ConstraintsBuilder(moduleName, line);
     }
 
-    public ChoiceBuilder(ChoiceBuilder b, QName qname) {
-        super(b.getModuleName(), b.getLine(), qname);
-        parent = b.getParent();
-        instance = new ChoiceNodeImpl(qname);
-        constraints = new ConstraintsBuilder(b.getConstraints());
-        schemaPath = b.getPath();
-        description = b.getDescription();
-        reference = b.getReference();
-        status = b.getStatus();
-        unknownNodes = b.unknownNodes;
-        addedUnknownNodes.addAll(b.getUnknownNodes());
-        augmenting = b.isAugmenting();
-        addedByUses = b.isAddedByUses();
-        configuration = b.isConfiguration();
-        addedAugmentations.addAll(b.getAugmentations());
-        cases = b.cases;
-        addedCases.addAll(b.getCases());
-        defaultCase = b.getDefaultCase();
-    }
-
     @Override
     public ChoiceNode build() {
         if (!isBuilt) {
@@ -127,6 +107,22 @@ public final class ChoiceBuilder extends AbstractSchemaNodeBuilder implements Da
         return addedCases;
     }
 
+    /**
+     * Get case by name.
+     *
+     * @param caseName
+     *            name of case to search
+     * @return case with given name if present, null otherwise
+     */
+    public ChoiceCaseBuilder getCaseNodeByName(String caseName) {
+        for (ChoiceCaseBuilder addedCase : addedCases) {
+            if (addedCase.getQName().getLocalName().equals(caseName)) {
+                return addedCase;
+            }
+        }
+        return null;
+    }
+
     /**
      * Add case node to this choice.
      *