Take advantage of ValueNode in NormalizedNodes 90/84490/1
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 15 Sep 2019 22:10:56 +0000 (00:10 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 16 Sep 2019 00:06:54 +0000 (02:06 +0200)
We can perform a single instanceof check instead of two to check
for LeafNode and LeafSetEntryNode. Also cleanup checks to remove
superfluous type arguments.

Change-Id: Id9964088ff0751217175cf1a8c6f13009a0276e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 383c8a118c7bf009c268ced6c2db555244054e04)

yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodes.java

index 829f98b671f42f5c265468dcdb0debe7b92cf382..682199351a076c4a5c85ada696b5a6a2fcfd70c2 100644 (file)
@@ -97,13 +97,13 @@ public final class NormalizedNodes {
     @SuppressWarnings({ "unchecked", "rawtypes" })
     public static Optional<NormalizedNode<?, ?>> getDirectChild(final NormalizedNode<?, ?> node,
             final PathArgument pathArg) {
-        if (node instanceof LeafNode<?> || node instanceof LeafSetEntryNode<?>) {
+        if (node instanceof ValueNode) {
             return Optional.empty();
-        } else if (node instanceof DataContainerNode<?>) {
+        } else if (node instanceof DataContainerNode) {
             return (Optional) ((DataContainerNode<?>) node).getChild(pathArg);
         } else if (node instanceof MapNode && pathArg instanceof NodeIdentifierWithPredicates) {
             return (Optional) ((MapNode) node).getChild((NodeIdentifierWithPredicates) pathArg);
-        } else if (node instanceof LeafSetNode<?> && pathArg instanceof NodeWithValue) {
+        } else if (node instanceof LeafSetNode && pathArg instanceof NodeWithValue) {
             return (Optional) ((LeafSetNode<?>) node).getChild((NodeWithValue) pathArg);
         }
         return Optional.empty();
@@ -125,7 +125,7 @@ public final class NormalizedNodes {
         final String prefix = Strings.repeat(" ", offset);
 
         builder.append(prefix).append(toStringTree(node.getIdentifier()));
-        if (node instanceof NormalizedNodeContainer<?, ?, ?>) {
+        if (node instanceof NormalizedNodeContainer) {
             final NormalizedNodeContainer<?, ?, ?> container = (NormalizedNodeContainer<?, ?, ?>) node;
 
             builder.append(" {\n");