Do not check whether two nodes can be merged with reference comparison 36/79536/2
authorTomas Cere <tomas.cere@pantheon.tech>
Tue, 15 Jan 2019 13:14:15 +0000 (14:14 +0100)
committerTomas Cere <tomas.cere@pantheon.tech>
Tue, 15 Jan 2019 13:18:50 +0000 (14:18 +0100)
These need to be compared with .equals().
Also fixup the wording slightly.

Change-Id: Ib723a9a2de9810234bdbd725326d6ebd7c4c4151
JIRA: NETCONF-600
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java

index a309c035527f320ecdb6b62328f1010d781f3a05..e5b2ba25930563e6366b8951ac3b9c2f2b537319 100644 (file)
@@ -494,11 +494,11 @@ public final class ReadDataTransactionUtil {
         }
 
         // merge data from config and state
-        return mapNode(stateDataNode, configDataNode);
+        return mergeStateAndConfigData(stateDataNode, configDataNode);
     }
 
     /**
-     * Map data by type of read node.
+     * Merge state and config data into a single NormalizedNode.
      *
      * @param stateDataNode
      *             data node of state data
@@ -507,9 +507,9 @@ public final class ReadDataTransactionUtil {
      * @return {@link NormalizedNode}
      */
     @Nonnull
-    private static NormalizedNode<?, ?> mapNode(@Nonnull final NormalizedNode<?, ?> stateDataNode,
-                                                         @Nonnull final NormalizedNode<?, ?> configDataNode) {
-        validPossibilityOfMergeNodes(stateDataNode, configDataNode);
+    private static NormalizedNode<?, ?> mergeStateAndConfigData(@Nonnull final NormalizedNode<?, ?> stateDataNode,
+                                                                @Nonnull final NormalizedNode<?, ?> configDataNode) {
+        validateNodeMerge(stateDataNode, configDataNode);
         if (configDataNode instanceof RpcDefinition) {
             return prepareRpcData(configDataNode, stateDataNode);
         } else {
@@ -518,19 +518,19 @@ public final class ReadDataTransactionUtil {
     }
 
     /**
-     * Valid of can be data merged together.
+     * Validates whether the two NormalizedNodes can be merged.
      *
      * @param stateDataNode
      *             data node of state data
      * @param configDataNode
      *             data node of config data
      */
-    private static void validPossibilityOfMergeNodes(@Nonnull final NormalizedNode<?, ?> stateDataNode,
-                                                     @Nonnull final NormalizedNode<?, ?> configDataNode) {
+    private static void validateNodeMerge(@Nonnull final NormalizedNode<?, ?> stateDataNode,
+                                          @Nonnull final NormalizedNode<?, ?> configDataNode) {
         final QNameModule moduleOfStateData = stateDataNode.getIdentifier().getNodeType().getModule();
         final QNameModule moduleOfConfigData = configDataNode.getIdentifier().getNodeType().getModule();
-        if (moduleOfStateData != moduleOfConfigData) {
-            throw new RestconfDocumentedException("It is not possible to merge ");
+        if (!moduleOfStateData.equals(moduleOfConfigData)) {
+            throw new RestconfDocumentedException("Unable to merge data from different modules.");
         }
     }