Simplify ModifierImpl.contextImpl() 48/104848/1
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 16:36:28 +0000 (17:36 +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>
(cherry picked from commit a83dfa8d5ff23238f182283945d868ab52a13035)

parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ModifierImpl.java

index 486ebf469dfa8ec8e0f81d6445b44871d7b15a75..5f30430a55831f951cbe4f0868207ba0d4641204 100644 (file)
@@ -134,9 +134,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() {