Use an instanceof pattern 55/104855/3
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 13 Mar 2023 18:21:06 +0000 (19:21 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 13 Mar 2023 19:06:09 +0000 (19:06 +0000)
InferredStatementContext uses check-and-cast, which we can simplify for
Java 17.

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

index 9bd41212df7efd409b09c04f9520a41ae08328ee..2190e66a25e0a350e68c6e73590ddbd70cb8e07b 100644 (file)
@@ -434,11 +434,10 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
         LOG.debug("Materializing child {} from {}", qname, templateQName);
 
         final StmtContext<?, ?, ?> template;
-        if (prototype instanceof InferredStatementContext) {
+        if (prototype instanceof InferredStatementContext<?, ?, ?> inferredPrototype) {
             // Note: we need to access namespace here, as the target statement may have already been populated, in which
             //       case we want to obtain the statement in local namespace storage.
-            template = ((InferredStatementContext<?, ?, ?>) prototype).getFromNamespace(ParserNamespaces.schemaTree(),
-                templateQName);
+            template = inferredPrototype.getFromNamespace(ParserNamespaces.schemaTree(), templateQName);
         } else {
             template = prototype.allSubstatementsStream()
                 .filter(stmt -> stmt.producesEffective(SchemaTreeEffectiveStatement.class)