Update ChoiceSchemaNode design
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / SchemaUtils.java
index 5e9546c02a3301674f38e02634846fe17a8e43b5..b1bd57459d768e84de4a5906d0c45ff733317392 100644 (file)
@@ -65,7 +65,7 @@ public final class SchemaUtils {
                         schema = dsn;
                     }
                 } else if (dsn instanceof ChoiceSchemaNode) {
-                    for (final ChoiceCaseNode choiceCase : ((ChoiceSchemaNode) dsn).getCases()) {
+                    for (final ChoiceCaseNode choiceCase : ((ChoiceSchemaNode) dsn).getCases().values()) {
 
                         final DataSchemaNode dataChildByName = choiceCase.getDataChildByName(qname);
                         if (dataChildByName != null) {
@@ -120,7 +120,7 @@ public final class SchemaUtils {
     }
 
     public static DataSchemaNode findSchemaForChild(final ChoiceSchemaNode schema, final QName childPartialQName) {
-        for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
+        for (final ChoiceCaseNode choiceCaseNode : schema.getCases().values()) {
             final Optional<DataSchemaNode> childSchema = findFirstSchema(childPartialQName,
                 choiceCaseNode.getChildNodes());
             if (childSchema.isPresent()) {
@@ -142,7 +142,7 @@ public final class SchemaUtils {
     }
 
     public static AugmentationSchemaNode findSchemaForAugment(final ChoiceSchemaNode schema, final Set<QName> qnames) {
-        for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
+        for (final ChoiceCaseNode choiceCaseNode : schema.getCases().values()) {
             final Optional<AugmentationSchemaNode> schemaForAugment = findAugment(choiceCaseNode, qnames);
             if (schemaForAugment.isPresent()) {
                 return schemaForAugment.get();
@@ -188,7 +188,7 @@ public final class SchemaUtils {
                     continue;
                 }
 
-                for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) childSchema).getCases()) {
+                for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) childSchema).getCases().values()) {
                     for (final QName qname : getChildNodesRecursive(choiceCaseNode)) {
                         mappedChoices.put(qname, (ChoiceSchemaNode) childSchema);
                     }
@@ -249,7 +249,7 @@ public final class SchemaUtils {
                         childNodesToAugmentation.put(qname, mostTopAugmentation);
                     }
                 } else if (child instanceof ChoiceSchemaNode) {
-                    for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) child).getCases()) {
+                    for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) child).getCases().values()) {
                         for (final QName qname : getChildNodesRecursive(choiceCaseNode)) {
                             childNodesToAugmentation.put(qname, mostTopAugmentation);
                         }
@@ -262,7 +262,7 @@ public final class SchemaUtils {
 
         // Choice Node has to map child nodes from all its cases
         if (schema instanceof ChoiceSchemaNode) {
-            for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) schema).getCases()) {
+            for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) schema).getCases().values()) {
                 if (!augments.containsKey(choiceCaseNode.getQName())) {
                     continue;
                 }
@@ -287,7 +287,7 @@ public final class SchemaUtils {
 
         for (final DataSchemaNode childSchema : nodeContainer.getChildNodes()) {
             if (childSchema instanceof ChoiceSchemaNode) {
-                for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) childSchema).getCases()) {
+                for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) childSchema).getCases().values()) {
                     allChildNodes.addAll(getChildNodesRecursive(choiceCaseNode));
                 }
             } else if (childSchema instanceof AugmentationSchemaNode || childSchema instanceof ChoiceCaseNode) {
@@ -322,7 +322,7 @@ public final class SchemaUtils {
         final Set<DataSchemaNode> realChildNodes = new HashSet<>();
         if (targetSchema instanceof ChoiceSchemaNode) {
             for (final DataSchemaNode dataSchemaNode : augmentSchema.getChildNodes()) {
-                for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) targetSchema).getCases()) {
+                for (final ChoiceCaseNode choiceCaseNode : ((ChoiceSchemaNode) targetSchema).getCases().values()) {
                     if (getChildNodesRecursive(choiceCaseNode).contains(dataSchemaNode.getQName())) {
                         realChildNodes.add(choiceCaseNode.getDataChildByName(dataSchemaNode.getQName()));
                     }
@@ -345,7 +345,7 @@ public final class SchemaUtils {
 
     public static Optional<ChoiceCaseNode> detectCase(final ChoiceSchemaNode schema,
             final DataContainerChild<?, ?> child) {
-        for (final ChoiceCaseNode choiceCaseNode : schema.getCases()) {
+        for (final ChoiceCaseNode choiceCaseNode : schema.getCases().values()) {
             if (child instanceof AugmentationNode
                     && belongsToCaseAugment(choiceCaseNode, (AugmentationIdentifier) child.getIdentifier())) {
                 return Optional.of(choiceCaseNode);