Update RuntimeRpc a bit 99/96299/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 21 May 2021 12:50:14 +0000 (14:50 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 21 May 2021 13:07:03 +0000 (15:07 +0200)
Move Element cast to the method which is producing it, saving one
import.

Change-Id: Ie00e716681666ae64f2774cf068a202e54fbeb81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/netconf/mdsal/connector/ops/RuntimeRpc.java

index 614d4b66c4b90faa1acf3b4c74460c7d4fe0bc50..37d48cfa06c3687365b2d37d418e98be8e076b5c 100644 (file)
@@ -52,7 +52,6 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.xml.sax.SAXException;
 
@@ -164,7 +163,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
             return XmlUtil.createElement(document, XmlNetconfConstants.OK,
                 Optional.of(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0));
         }
-        return (Element) transformNormalizedNode(document, result.getResult(), rpcDefinition.getOutput().getPath());
+        return transformNormalizedNode(document, result.getResult(), rpcDefinition.getOutput().getPath());
     }
 
     @Override
@@ -202,8 +201,8 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
         return document;
     }
 
-    private Node transformNormalizedNode(final Document document, final NormalizedNode<?, ?> data,
-                                         final SchemaPath rpcOutputPath) {
+    private Element transformNormalizedNode(final Document document, final NormalizedNode<?, ?> data,
+                                            final SchemaPath rpcOutputPath) {
         final DOMResult result = new DOMResult(document.createElement(XmlNetconfConstants.RPC_REPLY_KEY));
 
         final XMLStreamWriter xmlWriter = getXmlStreamWriter(result);
@@ -222,7 +221,7 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
             LOG.warn("Error while closing streams", e);
         }
 
-        return result.getNode();
+        return (Element) result.getNode();
     }
 
     private static XMLStreamWriter getXmlStreamWriter(final DOMResult result) {
@@ -267,5 +266,4 @@ public class RuntimeRpc extends AbstractSingletonNetconfOperation {
 
         return (ContainerNode) resultHolder.getResult();
     }
-
 }