BUG-1513: introduce ChoiceSchemaNode
authorRobert Varga <rovarga@cisco.com>
Tue, 10 Mar 2015 12:03:32 +0000 (13:03 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Tue, 10 Mar 2015 22:06:47 +0000 (23:06 +0100)
This introduces the alternative name, which does not clash with
yang-data-api. Also deprecated ChoiceNode.

Change-Id: I42e93c45804dc8e3952d08c697f772d776c303c3
Signed-off-by: Robert Varga <rovarga@cisco.com>
14 files changed:
code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/gen/impl/DataNodeContainerSerializerSource.java
code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/ChoiceNodeCodecContext.java
code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/DataContainerCodecPrototype.java
code-generator/binding-data-codec/src/main/java/org/opendaylight/yangtools/binding/data/codec/impl/SchemaRootCodecContext.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingSchemaContextUtils.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratorListener.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/TransformerGenerator.xtend
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/YangTemplate.xtend
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/util/BindingRuntimeContext.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/util/YangSchemaUtils.java
code-generator/binding-type-provider/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/GroupingDefinitionDependencySort.java
code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/yang/unified/doc/generator/GeneratorImpl.xtend

index 9b8faba4cb67a2a3bf36215dbc9796937ed9b48d..76d1cd01c6c79188eba4f470b992d453ec04cac0 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.DataObjectSerializerImplementation;
 import org.opendaylight.yangtools.yang.binding.DataObjectSerializerRegistry;
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -150,7 +150,7 @@ abstract class DataNodeContainerSerializerSource extends DataObjectSerializerSou
             emitList(b, getterName, valueType, casted);
         } else if (child instanceof ContainerSchemaNode) {
             b.append(statement(staticInvokeEmitter(childType, getterName)));
-        } else if (child instanceof ChoiceNode) {
+        } else if (child instanceof ChoiceSchemaNode) {
             String propertyName = CHOICE_PREFIX + childType.getName();
             staticConstant(propertyName, DataObjectSerializerImplementation.class, ChoiceDispatchSerializer.from(loadClass(childType)));
             b.append(statement(invoke(propertyName, StreamWriterGenerator.SERIALIZE_METHOD_NAME, REGISTRY, cast(DataObject.class.getName(),getterName), STREAM)));
index ee1d0083d3726d4192b6693e741813e3ee0a3c86..7f8877e29a23aa6fb6739b7647a851f0cbcc96f2 100644 (file)
@@ -25,18 +25,18 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class ChoiceNodeCodecContext extends DataContainerCodecContext<ChoiceNode> {
+final class ChoiceNodeCodecContext extends DataContainerCodecContext<ChoiceSchemaNode> {
     private static final Logger LOG = LoggerFactory.getLogger(ChoiceNodeCodecContext.class);
     private final ImmutableMap<YangInstanceIdentifier.PathArgument, DataContainerCodecPrototype<?>> byYangCaseChild;
     private final ImmutableMap<Class<?>, DataContainerCodecPrototype<?>> byClass;
     private final ImmutableMap<Class<?>, DataContainerCodecPrototype<?>> byCaseChildClass;
 
-    public ChoiceNodeCodecContext(final DataContainerCodecPrototype<ChoiceNode> prototype) {
+    public ChoiceNodeCodecContext(final DataContainerCodecPrototype<ChoiceSchemaNode> prototype) {
         super(prototype);
         Map<YangInstanceIdentifier.PathArgument, DataContainerCodecPrototype<?>> byYangCaseChildBuilder = new HashMap<>();
         Map<Class<?>, DataContainerCodecPrototype<?>> byClassBuilder = new HashMap<>();
index 696a53b99de6822ee131444f6897907f4a8cbd51..5d2ad801dcef7734b78e2229cbf9e80750dc218c 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
@@ -142,7 +142,7 @@ final class DataContainerCodecPrototype<T> implements NodeContextSupplier {
             } else {
                 return new ListNodeCodecContext((DataContainerCodecPrototype) this);
             }
-        } else if (schema instanceof ChoiceNode) {
+        } else if (schema instanceof ChoiceSchemaNode) {
             return new ChoiceNodeCodecContext((DataContainerCodecPrototype) this);
         } else if (schema instanceof AugmentationSchema) {
             return new AugmentationNodeContext((DataContainerCodecPrototype) this);
@@ -153,6 +153,6 @@ final class DataContainerCodecPrototype<T> implements NodeContextSupplier {
     }
 
     boolean isChoice() {
-        return schema instanceof ChoiceNode;
+        return schema instanceof ChoiceSchemaNode;
     }
 }
index 874a778817d944a5cfbb4b78dfc839031d85f9f3..9460bf2a173c8e0af046125b0e8608a83a9d0687 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -69,7 +69,7 @@ final class SchemaRootCodecContext extends DataContainerCodecContext<SchemaConte
                     Preconditions.checkArgument(childSchema != null, "Argument %s is not valid child of %s", qname,
                             schema());
 
-                    if (childSchema instanceof DataNodeContainer || childSchema instanceof ChoiceNode) {
+                    if (childSchema instanceof DataNodeContainer || childSchema instanceof ChoiceSchemaNode) {
                         final Class<?> childCls = factory().getRuntimeContext().getClassForSchema(childSchema);
                         return getStreamChild(childCls);
                     } else {
index ee0eb2e40db83280e0110fcc1ea49796402688a2..b6e3598ce1fc21126ce2e9f19be1e7f5f29efb30 100644 (file)
@@ -71,7 +71,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
@@ -824,7 +824,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             throw new NullPointerException("Target type not yet generated: " + targetSchemaNode);
         }
 
-        if (!(targetSchemaNode instanceof ChoiceNode)) {
+        if (!(targetSchemaNode instanceof ChoiceSchemaNode)) {
             String packageName = augmentPackageName;
             final Type targetType = new ReferencedTypeImpl(targetTypeBuilder.getPackageName(),
                     targetTypeBuilder.getName());
@@ -832,7 +832,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         } else {
             generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(),
-                    (ChoiceNode) targetSchemaNode, augSchema.getChildNodes());
+                    (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
         }
     }
 
@@ -858,7 +858,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
             throw new NullPointerException("Target type not yet generated: " + targetSchemaNode);
         }
 
-        if (!(targetSchemaNode instanceof ChoiceNode)) {
+        if (!(targetSchemaNode instanceof ChoiceSchemaNode)) {
             String packageName = augmentPackageName;
             if (usesNodeParent instanceof SchemaNode) {
                 packageName = packageNameForGeneratedType(augmentPackageName, ((SchemaNode) usesNodeParent).getPath(),
@@ -868,7 +868,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     augSchema);
         } else {
             generateTypesFromAugmentedChoiceCases(module, augmentPackageName, targetTypeBuilder.toInstance(),
-                    (ChoiceNode) targetSchemaNode, augSchema.getChildNodes());
+                    (ChoiceSchemaNode) targetSchemaNode, augSchema.getChildNodes());
         }
     }
 
@@ -895,8 +895,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
             // with same name and different namespace
             if (result instanceof DataNodeContainer) {
                 result = ((DataNodeContainer) result).getDataChildByName(node.getLocalName());
-            } else if (result instanceof ChoiceNode) {
-                result = ((ChoiceNode) result).getCaseNodeByName(node.getLocalName());
+            } else if (result instanceof ChoiceSchemaNode) {
+                result = ((ChoiceSchemaNode) result).getCaseNodeByName(node.getLocalName());
             }
         }
         if (result == null) {
@@ -1113,8 +1113,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 containerToGenType(module, basePackageName, typeBuilder, childOf, (ContainerSchemaNode) node);
             } else if (node instanceof ListSchemaNode) {
                 listToGenType(module, basePackageName, typeBuilder, childOf, (ListSchemaNode) node);
-            } else if (node instanceof ChoiceNode) {
-                choiceToGeneratedType(module, basePackageName, typeBuilder, (ChoiceNode) node);
+            } else if (node instanceof ChoiceSchemaNode) {
+                choiceToGeneratedType(module, basePackageName, typeBuilder, (ChoiceSchemaNode) node);
             } else {
                 // TODO: anyxml not yet supported
                 LOG.debug("Unable to add schema node {} as method in {}: unsupported type of node.", node.getClass(),
@@ -1147,7 +1147,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      */
     private void choiceToGeneratedType(final Module module, final String basePackageName,
-            final GeneratedTypeBuilder parent, final ChoiceNode choiceNode) {
+            final GeneratedTypeBuilder parent, final ChoiceSchemaNode choiceNode) {
         checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
         checkArgument(choiceNode != null, "Choice Schema Node cannot be NULL.");
 
@@ -1190,7 +1190,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      */
     private void generateTypesFromChoiceCases(final Module module, final String basePackageName,
-            final Type refChoiceType, final ChoiceNode choiceNode) {
+            final Type refChoiceType, final ChoiceSchemaNode choiceNode) {
         checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
         checkArgument(refChoiceType != null, "Referenced Choice Type cannot be NULL.");
         checkArgument(choiceNode != null, "ChoiceNode cannot be NULL.");
@@ -1273,7 +1273,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
      *             </ul>
      */
     private void generateTypesFromAugmentedChoiceCases(final Module module, final String basePackageName,
-            final Type targetType, final ChoiceNode targetNode, final Iterable<DataSchemaNode> augmentedNodes) {
+            final Type targetType, final ChoiceSchemaNode targetNode, final Iterable<DataSchemaNode> augmentedNodes) {
         checkArgument(basePackageName != null, "Base Package Name cannot be NULL.");
         checkArgument(targetType != null, "Referenced Choice Type cannot be NULL.");
         checkArgument(augmentedNodes != null, "Set of Choice Case Nodes cannot be NULL.");
@@ -1821,8 +1821,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 resolveLeafListSchemaNode(typeBuilder, (LeafListSchemaNode) schemaNode);
             } else if (schemaNode instanceof ContainerSchemaNode) {
                 containerToGenType(module, basePackageName, typeBuilder, typeBuilder, (ContainerSchemaNode) schemaNode);
-            } else if (schemaNode instanceof ChoiceNode) {
-                choiceToGeneratedType(module, basePackageName, typeBuilder, (ChoiceNode) schemaNode);
+            } else if (schemaNode instanceof ChoiceSchemaNode) {
+                choiceToGeneratedType(module, basePackageName, typeBuilder, (ChoiceSchemaNode) schemaNode);
             } else if (schemaNode instanceof ListSchemaNode) {
                 listToGenType(module, basePackageName, typeBuilder, typeBuilder, (ListSchemaNode) schemaNode);
             }
index 283a262e58817cd634e891b34677c1776008b708..4f8b5acb1821184260b1e670bb3313adf6ef96d3 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
@@ -90,8 +90,8 @@ public final class BindingSchemaContextUtils {
             final QName targetQName) {
 
         for (DataSchemaNode child : ctx.getChildNodes()) {
-            if (child instanceof ChoiceNode) {
-                DataNodeContainer potential = findInCases(((ChoiceNode) child), targetQName);
+            if (child instanceof ChoiceSchemaNode) {
+                DataNodeContainer potential = findInCases(((ChoiceSchemaNode) child), targetQName);
                 if (potential != null) {
                     return Optional.of(potential);
                 }
@@ -107,7 +107,7 @@ public final class BindingSchemaContextUtils {
         return Optional.absent();
     }
 
-    private static DataNodeContainer findInCases(final ChoiceNode choiceNode, final QName targetQName) {
+    private static DataNodeContainer findInCases(final ChoiceSchemaNode choiceNode, final QName targetQName) {
         for (ChoiceCaseNode caze : choiceNode.getCases()) {
             Optional<DataNodeContainer> potential = findDataNodeContainer(caze, targetQName);
             if (potential.isPresent()) {
@@ -165,24 +165,24 @@ public final class BindingSchemaContextUtils {
         return augmentations;
     }
 
-    public static Optional<ChoiceNode> findInstantiatedChoice(final DataNodeContainer parent, final Class<?> choiceClass) {
+    public static Optional<ChoiceSchemaNode> findInstantiatedChoice(final DataNodeContainer parent, final Class<?> choiceClass) {
         return findInstantiatedChoice(parent, BindingReflections.findQName(choiceClass));
     }
 
-    public static Optional<ChoiceNode> findInstantiatedChoice(final DataNodeContainer ctxNode, final QName choiceName) {
+    public static Optional<ChoiceSchemaNode> findInstantiatedChoice(final DataNodeContainer ctxNode, final QName choiceName) {
         DataSchemaNode potential = ctxNode.getDataChildByName(choiceName);
         if (potential == null) {
             potential = ctxNode.getDataChildByName(choiceName.getLocalName());
         }
 
-        if (potential instanceof ChoiceNode) {
-            return Optional.of((ChoiceNode) potential);
+        if (potential instanceof ChoiceSchemaNode) {
+            return Optional.of((ChoiceSchemaNode) potential);
         }
 
         return Optional.absent();
     }
 
-    public static Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceNode instantiatedChoice, final ChoiceCaseNode originalDefinition) {
+    public static Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceSchemaNode instantiatedChoice, final ChoiceCaseNode originalDefinition) {
         ChoiceCaseNode potential = instantiatedChoice.getCaseNodeByName(originalDefinition.getQName());
         if(originalDefinition.equals(potential)) {
             return Optional.of(potential);
index a67550954583d7b4062297874df5fb5103fc5b02..4ffeca2417156110f690b009c797d561a53806d5 100644 (file)
@@ -8,10 +8,9 @@
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
 import java.util.Map;
-
 import org.opendaylight.yangtools.yang.binding.BindingCodec;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 
 public interface GeneratorListener {
     void onClassProcessed(Class<?> cl);
@@ -22,5 +21,5 @@ public interface GeneratorListener {
     void onDataContainerCodecCreated(Class<?> dataClass, Class<? extends BindingCodec<?, ?>> dataCodec);
 
     void onChoiceCodecCreated(Class<?> choiceClass,
-                              Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, ChoiceNode schema);
+                              Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, ChoiceSchemaNode schema);
 }
index 8a4c1c9eb7def73bddc02c2396297ab26162692f..44563e91e233449805d7bf7788416d980db593e2 100644 (file)
@@ -66,7 +66,7 @@ import org.opendaylight.yangtools.yang.data.impl.codec.ValueWithQName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
@@ -281,8 +281,8 @@ class LazyGeneratedCodecRegistry implements CodecRegistry, SchemaContextListener
 
     private DataSchemaNode searchInChoices(final DataNodeContainer node, final QName arg) {
         for (DataSchemaNode child : node.getChildNodes()) {
-            if (child instanceof ChoiceNode) {
-                ChoiceNode choiceNode = (ChoiceNode) child;
+            if (child instanceof ChoiceSchemaNode) {
+                ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) child;
                 DataSchemaNode potential = searchInCases(choiceNode, arg);
                 if (potential != null) {
                     return potential;
@@ -292,7 +292,7 @@ class LazyGeneratedCodecRegistry implements CodecRegistry, SchemaContextListener
         return null;
     }
 
-    private DataSchemaNode searchInCases(final ChoiceNode choiceNode, final QName arg) {
+    private DataSchemaNode searchInCases(final ChoiceSchemaNode choiceNode, final QName arg) {
         Set<ChoiceCaseNode> cases = choiceNode.getCases();
         for (ChoiceCaseNode caseNode : cases) {
             DataSchemaNode node = caseNode.getDataChildByName(arg);
@@ -449,7 +449,7 @@ class LazyGeneratedCodecRegistry implements CodecRegistry, SchemaContextListener
     @SuppressWarnings({ "unchecked", "rawtypes" })
     @Override
     public void onChoiceCodecCreated(final Class<?> choiceClass,
-            final Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, final ChoiceNode schema) {
+            final Class<? extends BindingCodec<Map<QName, Object>, Object>> choiceCodec, final ChoiceSchemaNode schema) {
         ChoiceCodec<?> oldCodec = choiceCodecs.get(choiceClass);
         Preconditions.checkState(oldCodec == null);
         BindingCodec<Map<QName, Object>, Object> delegate = newInstanceOf(choiceCodec);
@@ -984,12 +984,12 @@ class LazyGeneratedCodecRegistry implements CodecRegistry, SchemaContextListener
         @Override
         protected void adaptForPathImpl(final InstanceIdentifier<?> augTarget, final DataNodeContainer ctxNode) {
             tryToLoadImplementations();
-            Optional<ChoiceNode> newChoice = BindingSchemaContextUtils.findInstantiatedChoice(ctxNode, choiceType);
+            Optional<ChoiceSchemaNode> newChoice = BindingSchemaContextUtils.findInstantiatedChoice(ctxNode, choiceType);
             if(!newChoice.isPresent()) {
                 // Choice is nested inside other choice, so we need to look two levels deep.
                 in_choices: for(DataSchemaNode child : ctxNode.getChildNodes()) {
-                    if(child instanceof ChoiceNode) {
-                        Optional<ChoiceNode> potential = findChoiceInChoiceCases((ChoiceNode) child, choiceType);
+                    if (child instanceof ChoiceSchemaNode) {
+                        Optional<ChoiceSchemaNode> potential = findChoiceInChoiceCases((ChoiceSchemaNode) child, choiceType);
                         if(potential.isPresent()) {
                             newChoice = potential;
                             break in_choices;
@@ -1010,9 +1010,9 @@ class LazyGeneratedCodecRegistry implements CodecRegistry, SchemaContextListener
             }
         }
 
-        private Optional<ChoiceNode> findChoiceInChoiceCases(final ChoiceNode choice, final Class<?> choiceType) {
+        private Optional<ChoiceSchemaNode> findChoiceInChoiceCases(final ChoiceSchemaNode choice, final Class<?> choiceType) {
             for(ChoiceCaseNode caze : choice.getCases()) {
-                Optional<ChoiceNode> potential = BindingSchemaContextUtils.findInstantiatedChoice(caze, choiceType);
+                Optional<ChoiceSchemaNode> potential = BindingSchemaContextUtils.findInstantiatedChoice(caze, choiceType);
                 if(potential.isPresent()) {
                     return potential;
                 }
index 889f8ebee0e00204e2b36532152d0e5919e11757..74f40519679b030c21920efbd300f1257b5a30e8 100644 (file)
@@ -7,6 +7,12 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl
 
+import static com.google.common.base.Preconditions.*
+import static javassist.Modifier.*
+import static org.opendaylight.yangtools.sal.binding.generator.impl.CodecMapping.*
+
+import static extension org.opendaylight.yangtools.sal.binding.generator.util.YangSchemaUtils.*
+
 import com.google.common.base.Joiner
 import com.google.common.base.Supplier
 import java.io.File
@@ -49,7 +55,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
 import org.opendaylight.yangtools.yang.common.QName
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
@@ -67,12 +73,6 @@ import org.opendaylight.yangtools.yang.model.util.EnumerationType
 import org.opendaylight.yangtools.yang.model.util.ExtendedType
 import org.slf4j.LoggerFactory
 
-import static com.google.common.base.Preconditions.*
-import static javassist.Modifier.*
-import static org.opendaylight.yangtools.sal.binding.generator.impl.CodecMapping.*
-
-import static extension org.opendaylight.yangtools.sal.binding.generator.util.YangSchemaUtils.*
-
 class TransformerGenerator extends AbstractTransformerGenerator {
     private static val LOG = LoggerFactory.getLogger(TransformerGenerator)
 
@@ -222,8 +222,8 @@ class TransformerGenerator extends AbstractTransformerGenerator {
             val Map<String, Type> properties = typeSpec.allProperties
             if (node instanceof DataNodeContainer) {
                 mappingForNodes((node as DataNodeContainer).childNodes, properties, parent)
-            } else if (node instanceof ChoiceNode) {
-                mappingForNodes((node as ChoiceNode).cases, properties, parent)
+            } else if (node instanceof ChoiceSchemaNode) {
+                mappingForNodes((node as ChoiceSchemaNode).cases, properties, parent)
             }
             return null ]
         ClassLoaderUtils.withClassLoader(cl, sup)
@@ -651,7 +651,7 @@ class TransformerGenerator extends AbstractTransformerGenerator {
     }
 
     private def dispatch  Class<? extends BindingCodec<Map<QName, Object>, Object>> generateTransformerFor(
-        Class<?> inputType, GeneratedType typeSpec, ChoiceNode node) {
+        Class<?> inputType, GeneratedType typeSpec, ChoiceSchemaNode node) {
         try {
 
             val SourceCodeGenerator sourceGenerator = sourceCodeGeneratorFactory.getInstance( null );
@@ -918,7 +918,7 @@ class TransformerGenerator extends AbstractTransformerGenerator {
         }
     '''
 
-    private def dispatch CharSequence deserializeProperty(ChoiceNode schema, Type type, String propertyName) '''
+    private def dispatch CharSequence deserializeProperty(ChoiceSchemaNode schema, Type type, String propertyName) '''
         «type.resolvedName» «propertyName» = «type.serializer(schema).resolvedName».fromDomStatic(_localQName,_compositeNode,$3);
         if(«propertyName» != null) {
             _is_empty = false;
@@ -1599,7 +1599,7 @@ class TransformerGenerator extends AbstractTransformerGenerator {
         }
     '''
 
-    private def dispatch CharSequence serializeProperty(ChoiceNode container, GeneratedType type,
+    private def dispatch CharSequence serializeProperty(ChoiceSchemaNode container, GeneratedType type,
         String propertyName) '''
         «type.resolvedName» «propertyName» = value.«propertyName»();
         if(«propertyName» != null) {
index f6e2ed7d249e3402bfff67fab1976c9ce051a655..913d68542a79a8b4c7e63eac7cf4e0994648d626 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.common.QName
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
 import org.opendaylight.yangtools.yang.model.api.Deviation
@@ -645,7 +645,7 @@ class YangTemplate {
         '''
     }
 
-    def static writeChoiceNode(ChoiceNode choiceNode) {
+    def static writeChoiceNode(ChoiceSchemaNode choiceNode) {
         '''
             choice «choiceNode.getQName.localName» {
                 «FOR child : choiceNode.cases»
@@ -696,7 +696,7 @@ class YangTemplate {
             «IF child instanceof ChoiceCaseNode»
                 «writeChoiceCaseNode(child)»
             «ENDIF»
-            «IF child instanceof ChoiceNode»
+            «IF child instanceof ChoiceSchemaNode»
                 «writeChoiceNode(child)»
             «ENDIF»
             «IF child instanceof ListSchemaNode»
index caf22b85984df6407bfdeaabbf90a15715d61afe..d79df4ef19e90e26b0dea0bbaae656cbccf06421 100644 (file)
@@ -44,7 +44,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.Augmentat
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -229,7 +229,7 @@ public class BindingRuntimeContext implements Immutable {
      *         the given context.
      * @throws IllegalArgumentException If supplied class does not represent case.
      */
-    public Optional<ChoiceCaseNode> getCaseSchemaDefinition(final ChoiceNode schema, final Class<?> childClass) throws IllegalArgumentException {
+    public Optional<ChoiceCaseNode> getCaseSchemaDefinition(final ChoiceSchemaNode schema, final Class<?> childClass) throws IllegalArgumentException {
         final DataSchemaNode origSchema = getSchemaDefinition(childClass);
         Preconditions.checkArgument(origSchema instanceof ChoiceCaseNode, "Supplied schema %s is not case.", origSchema);
 
@@ -274,8 +274,8 @@ public class BindingRuntimeContext implements Immutable {
 
     public ImmutableMap<Type, Entry<Type, Type>> getChoiceCaseChildren(final DataNodeContainer schema) {
         final Map<Type,Entry<Type,Type>> childToCase = new HashMap<>();;
-        for (final ChoiceNode choice :  FluentIterable.from(schema.getChildNodes()).filter(ChoiceNode.class)) {
-            final ChoiceNode originalChoice = getOriginalSchema(choice);
+        for (final ChoiceSchemaNode choice :  FluentIterable.from(schema.getChildNodes()).filter(ChoiceSchemaNode.class)) {
+            final ChoiceSchemaNode originalChoice = getOriginalSchema(choice);
             final Type choiceType = referencedType(typeToDefiningSchema.inverse().get(originalChoice));
             final Collection<Type> cases = choiceToCases.get(choiceType);
 
index 1084a0bf0f7dc8139825d3cbef4f83cf3abbdff4..5c35454039931e8a45b16e2b77c69f8ab3e76552 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.sal.binding.generator.util;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
-
 import com.google.common.base.Preconditions;
 import java.net.URI;
 import java.util.Date;
@@ -17,7 +16,7 @@ import java.util.Iterator;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
@@ -87,10 +86,10 @@ public final class YangSchemaUtils {
             final DataSchemaNode child = currentNode.getDataChildByName(currentArg);
             if(child instanceof DataNodeContainer) {
                 currentNode = (DataNodeContainer) child;
-            } else if (child instanceof ChoiceNode) {
+            } else if (child instanceof ChoiceSchemaNode) {
                 final QName caseQName = arguments.next();
                 Preconditions.checkArgument(arguments.hasNext(), "Path must not refer case only.");
-                currentNode = ((ChoiceNode) child).getCaseNodeByName(caseQName);
+                currentNode = ((ChoiceSchemaNode) child).getCaseNodeByName(caseQName);
             } else {
                 // Search in grouping
                 for( final GroupingDefinition grouping : currentNode.getGroupings()) {
index 2657fcbaba44475fbf96a0d3bed196656384ba2e..ece776fbcf1031470f52350e7d9efff7b2606cad 100644 (file)
@@ -9,17 +9,15 @@ package org.opendaylight.yangtools.sal.binding.yang.types;
 
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
@@ -149,8 +147,8 @@ public class GroupingDefinitionDependencySort {
         for (DataSchemaNode childNode : container.getChildNodes()) {
             if (childNode instanceof DataNodeContainer) {
                 ret.addAll(getAllUsesNodes((DataNodeContainer) childNode));
-            } else if (childNode instanceof ChoiceNode) {
-                Set<ChoiceCaseNode> cases = ((ChoiceNode) childNode).getCases();
+            } else if (childNode instanceof ChoiceSchemaNode) {
+                Set<ChoiceCaseNode> cases = ((ChoiceSchemaNode) childNode).getCases();
                 for (ChoiceCaseNode choiceCaseNode : cases) {
                     ret.addAll(getAllUsesNodes(choiceCaseNode));
                 }
index 853117786f1727d3205b2ae729ecc389463e33b5..6cd4960c66203c16820024a5a2b707e3014d1bbb 100644 (file)
@@ -27,7 +27,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
-import org.opendaylight.yangtools.yang.model.api.ChoiceNode
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
@@ -420,13 +420,13 @@ class GeneratorImpl {
         «IF child instanceof ListSchemaNode»
             «printListNode(child)»
         «ENDIF»
-        «IF child instanceof ChoiceNode»
+        «IF child instanceof ChoiceSchemaNode»
             «printChoiceNode(child)»
         «ENDIF»
         '''
     }
     
-    private def printChoiceNode(ChoiceNode child) {
+    private def printChoiceNode(ChoiceSchemaNode child) {
         val List<ChoiceCaseNode> cases = new ArrayList(child.cases);
         if(!cases.empty) {
             val ChoiceCaseNode aCase = cases.get(0)
@@ -755,7 +755,7 @@ class GeneratorImpl {
         «module.childNodes.treeSet(YangInstanceIdentifier.builder.build())»
     '''
 
-    private def dispatch CharSequence tree(ChoiceNode node,YangInstanceIdentifier path) '''
+    private def dispatch CharSequence tree(ChoiceSchemaNode node,YangInstanceIdentifier path) '''
         «node.nodeName» (choice)
         «casesTree(node.cases,path)»
     '''
@@ -865,7 +865,7 @@ class GeneratorImpl {
                 «ENDFOR»
                 </ul>
             '''
-        } else if(node instanceof ChoiceNode) {
+        } else if(node instanceof ChoiceSchemaNode) {
             return '''
                 «printInfo(node, "choice")»
                 «listItem("default case", node.defaultCase)»
@@ -944,7 +944,7 @@ class GeneratorImpl {
         val anyxmlNodes = nodes.filter(AnyXmlSchemaNode)
         val leafNodes = nodes.filter(LeafSchemaNode)
         val leafListNodes = nodes.filter(LeafListSchemaNode)
-        val choices = nodes.filter(ChoiceNode)
+        val choices = nodes.filter(ChoiceSchemaNode)
         val cases = nodes.filter(ChoiceCaseNode)
         val containers = nodes.filter(ContainerSchemaNode)
         val lists = nodes.filter(ListSchemaNode)
@@ -1075,7 +1075,7 @@ class GeneratorImpl {
         «node.childNodes.printChildren(level,newPath)»
     '''
 
-    private def dispatch CharSequence printInfo(ChoiceNode node, int level, YangInstanceIdentifier path) '''
+    private def dispatch CharSequence printInfo(ChoiceSchemaNode node, int level, YangInstanceIdentifier path) '''
         «val Set<DataSchemaNode> choiceCases = new HashSet(node.cases)»
         «choiceCases.printChildren(level,path)»
     '''
@@ -1228,7 +1228,7 @@ class GeneratorImpl {
                 pathString.append(':')
                 pathString.append(name.localName)
                 pathString.append('/')
-                if(node instanceof ChoiceNode && dataNode !== null) {
+                if(node instanceof ChoiceSchemaNode && dataNode !== null) {
                     val DataSchemaNode caseNode = dataNode.childNodes.findFirst[DataSchemaNode e | e instanceof ChoiceCaseNode];
                     if(caseNode !== null) {
                         pathString.append("(case)");
@@ -1406,7 +1406,7 @@ class GeneratorImpl {
     '''
 
     private def String nodeSchemaPathToPath(DataSchemaNode node, Map<SchemaPath, DataSchemaNode> childNodes) {
-        if (node instanceof ChoiceNode || node instanceof ChoiceCaseNode) {
+        if (node instanceof ChoiceSchemaNode || node instanceof ChoiceCaseNode) {
             return null
         }
 
@@ -1422,7 +1422,7 @@ class GeneratorImpl {
             for (pathElement : path) {
                 actual.add(pathElement)
                 val DataSchemaNode nodeByPath = childNodes.get(SchemaPath.create(actual, absolute))
-                if (!(nodeByPath instanceof ChoiceNode) && !(nodeByPath instanceof ChoiceCaseNode)) {
+                if (!(nodeByPath instanceof ChoiceSchemaNode) && !(nodeByPath instanceof ChoiceCaseNode)) {
                     result.append(pathElement.localName)
                     if (i != path.size - 1) {
                         result.append("/")
@@ -1440,7 +1440,7 @@ class GeneratorImpl {
             if (node instanceof DataNodeContainer) {
                 collectChildNodes((node as DataNodeContainer).childNodes, destination)
             }
-            if (node instanceof ChoiceNode) {
+            if (node instanceof ChoiceSchemaNode) {
                 val List<DataSchemaNode> choiceCases = new ArrayList()
                 for (caseNode : node.cases) {
                     choiceCases.add(caseNode)