Simplify ModifierImpl.contextImpl() 44/104844/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 13 Mar 2023 15:04:36 +0000 (16:04 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 13 Mar 2023 15:42:47 +0000 (16:42 +0100)
Use an instanceof pattern to make the check we are making more
transparent.

Change-Id: If6d92be744e1e063f96feb7428c09c4984cf2c9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ModifierImpl.java

index d857e2b2533cdc574865fbb2f4fb431704a180c0..a802fecb1dc94be886fd46428e4ece42cc97d311 100644 (file)
@@ -133,9 +133,10 @@ final class ModifierImpl implements ModelActionBuilder {
     }
 
     private static StatementContextBase<?, ?, ?> contextImpl(final Object value) {
-        checkArgument(value instanceof StatementContextBase, "Supplied context %s is not provided by this reactor.",
-            value);
-        return StatementContextBase.class.cast(value);
+        if (value instanceof StatementContextBase<?, ?, ?> impl) {
+            return impl;
+        }
+        throw new IllegalArgumentException("Supplied context " + value + " is not provided by this reactor.");
     }
 
     boolean tryApply() {