Bump MRI upstreams
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / jersey / providers / ParameterAwareNormalizedNodeWriter.java
index 64b305639327190e5f54e90fec86f28298ba6348..b7278c46789f0fff383901e8db3d4df3ce0524df 100644 (file)
@@ -32,10 +32,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
-import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserLeafSetNode;
+import org.opendaylight.yangtools.yang.data.api.schema.UserMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -113,7 +113,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
      * @throws IOException when thrown from the backing writer.
      */
     @Override
-    public final ParameterAwareNormalizedNodeWriter write(final NormalizedNode<?, ?> node) throws IOException {
+    public final ParameterAwareNormalizedNodeWriter write(final NormalizedNode node) throws IOException {
         if (wasProcessedAsCompositeNode(node)) {
             return this;
         }
@@ -148,29 +148,29 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
         return children instanceof Collection ? ((Collection<?>) children).size() : UNKNOWN_SIZE;
     }
 
-    private boolean wasProcessAsSimpleNode(final NormalizedNode<?, ?> node) throws IOException {
+    private boolean wasProcessAsSimpleNode(final NormalizedNode node) throws IOException {
         if (node instanceof LeafSetEntryNode) {
             if (selectedByParameters(node, false)) {
                 final LeafSetEntryNode<?> nodeAsLeafList = (LeafSetEntryNode<?>) node;
                 writer.startLeafSetEntryNode(nodeAsLeafList.getIdentifier());
-                writer.scalarValue(nodeAsLeafList.getValue());
+                writer.scalarValue(nodeAsLeafList.body());
                 writer.endNode();
             }
             return true;
         } else if (node instanceof LeafNode) {
             final LeafNode<?> nodeAsLeaf = (LeafNode<?>)node;
             writer.startLeafNode(nodeAsLeaf.getIdentifier());
-            writer.scalarValue(nodeAsLeaf.getValue());
+            writer.scalarValue(nodeAsLeaf.body());
             writer.endNode();
             return true;
         } else if (node instanceof AnyxmlNode) {
             final AnyxmlNode<?> anyxmlNode = (AnyxmlNode<?>)node;
-            final Class<?> objectModel = anyxmlNode.getValueObjectModel();
+            final Class<?> objectModel = anyxmlNode.bodyObjectModel();
             if (writer.startAnyxmlNode(anyxmlNode.getIdentifier(), objectModel)) {
                 if (DOMSource.class.isAssignableFrom(objectModel)) {
-                    writer.domSourceValue((DOMSource) anyxmlNode.getValue());
+                    writer.domSourceValue((DOMSource) anyxmlNode.body());
                 } else {
-                    writer.scalarValue(anyxmlNode.getValue());
+                    writer.scalarValue(anyxmlNode.body());
                 }
                 writer.endNode();
             }
@@ -187,7 +187,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
      * @param mixinParent {@code true} if parent is mixin, {@code false} otherwise
      * @return {@code true} if node will be written, {@code false} otherwise
      */
-    protected boolean selectedByParameters(final NormalizedNode<?, ?> node, final boolean mixinParent) {
+    protected boolean selectedByParameters(final NormalizedNode node, final boolean mixinParent) {
         // nodes to be written are not limited by fields, only by depth
         if (fields == null) {
             return maxDepth == null || currentDepth < maxDepth;
@@ -205,7 +205,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
 
         // write only selected nodes
         if (currentDepth > 0 && currentDepth <= fields.size()) {
-            return fields.get(currentDepth - 1).contains(node.getNodeType());
+            return fields.get(currentDepth - 1).contains(node.getIdentifier().getNodeType());
         }
 
         // after this depth only depth parameter is used to determine when to write node
@@ -220,9 +220,9 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
      * @return True
      * @throws IOException when the writer reports it
      */
-    protected final boolean writeChildren(final Iterable<? extends NormalizedNode<?, ?>> children,
+    protected final boolean writeChildren(final Iterable<? extends NormalizedNode> children,
                                           final boolean mixinParent) throws IOException {
-        for (final NormalizedNode<?, ?> child : children) {
+        for (final NormalizedNode child : children) {
             if (selectedByParameters(child, mixinParent)) {
                 write(child);
             }
@@ -233,7 +233,7 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
 
     protected boolean writeMapEntryChildren(final MapEntryNode mapEntryNode) throws IOException {
         if (selectedByParameters(mapEntryNode, false)) {
-            writeChildren(mapEntryNode.getValue(), false);
+            writeChildren(mapEntryNode.body(), false);
         } else if (fields == null && maxDepth != null && currentDepth == maxDepth) {
             writeOnlyKeys(mapEntryNode.getIdentifier().entrySet());
         }
@@ -250,25 +250,25 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
     }
 
     protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException {
-        writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()));
+        writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.body()));
         currentDepth++;
         writeMapEntryChildren(node);
         currentDepth--;
         return true;
     }
 
-    private boolean wasProcessedAsCompositeNode(final NormalizedNode<?, ?> node) throws IOException {
+    private boolean wasProcessedAsCompositeNode(final NormalizedNode node) throws IOException {
         boolean processedAsCompositeNode = false;
         if (node instanceof ContainerNode) {
             final ContainerNode n = (ContainerNode) node;
-            if (!n.getNodeType().withoutRevision().equals(ROOT_DATA_QNAME)) {
-                writer.startContainerNode(n.getIdentifier(), childSizeHint(n.getValue()));
+            if (!n.getIdentifier().getNodeType().withoutRevision().equals(ROOT_DATA_QNAME)) {
+                writer.startContainerNode(n.getIdentifier(), childSizeHint(n.body()));
                 currentDepth++;
-                processedAsCompositeNode = writeChildren(n.getValue(), false);
+                processedAsCompositeNode = writeChildren(n.body(), false);
                 currentDepth--;
             } else {
                 // write child nodes of data root container
-                for (final NormalizedNode<?, ?> child : n.getValue()) {
+                for (final NormalizedNode child : n.body()) {
                     currentDepth++;
                     if (selectedByParameters(child, false)) {
                         write(child);
@@ -281,39 +281,39 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
             processedAsCompositeNode = writeMapEntryNode((MapEntryNode) node);
         } else if (node instanceof UnkeyedListEntryNode) {
             final UnkeyedListEntryNode n = (UnkeyedListEntryNode) node;
-            writer.startUnkeyedListItem(n.getIdentifier(), childSizeHint(n.getValue()));
+            writer.startUnkeyedListItem(n.getIdentifier(), childSizeHint(n.body()));
             currentDepth++;
-            processedAsCompositeNode = writeChildren(n.getValue(), false);
+            processedAsCompositeNode = writeChildren(n.body(), false);
             currentDepth--;
         } else if (node instanceof ChoiceNode) {
             final ChoiceNode n = (ChoiceNode) node;
-            writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.getValue()));
-            processedAsCompositeNode = writeChildren(n.getValue(), true);
+            writer.startChoiceNode(n.getIdentifier(), childSizeHint(n.body()));
+            processedAsCompositeNode = writeChildren(n.body(), true);
         } else if (node instanceof AugmentationNode) {
             final AugmentationNode n = (AugmentationNode) node;
             writer.startAugmentationNode(n.getIdentifier());
-            processedAsCompositeNode = writeChildren(n.getValue(), true);
+            processedAsCompositeNode = writeChildren(n.body(), true);
         } else if (node instanceof UnkeyedListNode) {
             final UnkeyedListNode n = (UnkeyedListNode) node;
-            writer.startUnkeyedList(n.getIdentifier(), childSizeHint(n.getValue()));
-            processedAsCompositeNode = writeChildren(n.getValue(), false);
-        } else if (node instanceof OrderedMapNode) {
-            final OrderedMapNode n = (OrderedMapNode) node;
-            writer.startOrderedMapNode(n.getIdentifier(), childSizeHint(n.getValue()));
-            processedAsCompositeNode = writeChildren(n.getValue(), true);
+            writer.startUnkeyedList(n.getIdentifier(), childSizeHint(n.body()));
+            processedAsCompositeNode = writeChildren(n.body(), false);
+        } else if (node instanceof UserMapNode) {
+            final UserMapNode n = (UserMapNode) node;
+            writer.startOrderedMapNode(n.getIdentifier(), childSizeHint(n.body()));
+            processedAsCompositeNode = writeChildren(n.body(), true);
         } else if (node instanceof MapNode) {
             final MapNode n = (MapNode) node;
-            writer.startMapNode(n.getIdentifier(), childSizeHint(n.getValue()));
-            processedAsCompositeNode = writeChildren(n.getValue(), true);
+            writer.startMapNode(n.getIdentifier(), childSizeHint(n.body()));
+            processedAsCompositeNode = writeChildren(n.body(), true);
         } else if (node instanceof LeafSetNode) {
             final LeafSetNode<?> n = (LeafSetNode<?>) node;
-            if (node instanceof OrderedLeafSetNode) {
-                writer.startOrderedLeafSet(n.getIdentifier(), childSizeHint(n.getValue()));
+            if (node instanceof UserLeafSetNode) {
+                writer.startOrderedLeafSet(n.getIdentifier(), childSizeHint(n.body()));
             } else {
-                writer.startLeafSet(n.getIdentifier(), childSizeHint(n.getValue()));
+                writer.startLeafSet(n.getIdentifier(), childSizeHint(n.body()));
             }
             currentDepth++;
-            processedAsCompositeNode = writeChildren(n.getValue(), true);
+            processedAsCompositeNode = writeChildren(n.body(), true);
             currentDepth--;
         }
 
@@ -331,13 +331,13 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
         @Override
         protected boolean writeMapEntryNode(final MapEntryNode node) throws IOException {
             final NormalizedNodeStreamWriter writer = getWriter();
-            writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.getValue()));
+            writer.startMapEntryNode(node.getIdentifier(), childSizeHint(node.body()));
 
             final Set<QName> qnames = node.getIdentifier().keySet();
             // Write out all the key children
             currentDepth++;
             for (final QName qname : qnames) {
-                final Optional<? extends NormalizedNode<?, ?>> child = node.getChild(new NodeIdentifier(qname));
+                final Optional<? extends NormalizedNode> child = node.findChildByArg(new NodeIdentifier(qname));
                 if (child.isPresent()) {
                     if (selectedByParameters(child.get(), false)) {
                         write(child.get());
@@ -351,11 +351,11 @@ public class ParameterAwareNormalizedNodeWriter implements RestconfNormalizedNod
             currentDepth++;
             // Write all the rest
             final boolean result =
-                    writeChildren(Iterables.filter(node.getValue(), input -> {
+                    writeChildren(Iterables.filter(node.body(), input -> {
                         if (input instanceof AugmentationNode) {
                             return true;
                         }
-                        if (!qnames.contains(input.getNodeType())) {
+                        if (!qnames.contains(input.getIdentifier().getNodeType())) {
                             return true;
                         }