Simplify check for tree/node match 72/28672/4
authorRobert Varga <robert.varga@pantheon.sk>
Wed, 21 Oct 2015 23:16:18 +0000 (01:16 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 23 Nov 2015 08:19:01 +0000 (08:19 +0000)
The check can be inverted to check for:

All nodes belong in TreeType.OPERATIONAL. Nodes which are in
TreeType.CONFIGURATION return this as a property.

Which can be written as a simple expression. Also expand javadoc a bit.

Change-Id: Ie10d9b4bc3f9f1e2d08f592cfec1bf4bc92ea21b
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/SchemaAwareApplyOperation.java

index b119a64664a130f17bfe660687b183894146780b..f07844c43515a2e2ac29b599757070b2747931f5 100644 (file)
@@ -261,16 +261,14 @@ abstract class SchemaAwareApplyOperation extends ModificationApplyOperation {
             final Optional<TreeNode> current) throws DataValidationFailedException;
 
     /**
-     * Checks if supplied schema node belong to specified Data Tree type.
+     * Checks if supplied schema node belong to specified Data Tree type. All nodes belong to the operational tree,
+     * nodes in configuration tree are marked as such.
      *
      * @param treeType Tree Type
      * @param node Schema node
      * @return
      */
     static boolean belongsToTree(final TreeType treeType, final DataSchemaNode node) {
-        if(treeType == TreeType.CONFIGURATION) {
-            return node.isConfiguration();
-        }
-        return true;
+        return treeType == TreeType.OPERATIONAL || node.isConfiguration();
     }
 }