Take advantage of ValueNode in NormalizedNodes 88/84488/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:39 +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 35b3abc3d97bc4df2d052326c7dc06ccabbaf3a7..014c4b8d5f89cd0d9a950b1a08cf38bcf327e52b 100644 (file)
@@ -90,13 +90,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();
@@ -118,7 +118,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");