Clean up binding-model stuff a bit
[yangtools.git] / parser / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / type / LeafrefSpecificationSupport.java
index d8fbb01d12e0af097d46d51c9830fa8bfadbd948..a06def1e4160ea8d5212a35f6e127c0d71744532 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.yangtools.yang.model.api.stmt.PathEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.LeafrefSpecification;
 import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
-import org.opendaylight.yangtools.yang.model.ri.type.LeafrefTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.spi.meta.BoundStmtCtx;
 import org.opendaylight.yangtools.yang.parser.spi.meta.CommonStmtCtx;
@@ -69,13 +68,15 @@ final class LeafrefSpecificationSupport extends AbstractTypeSupport<LeafrefSpeci
             throw noPath(stmt);
         }
 
-        final LeafrefTypeBuilder builder = BaseTypes.leafrefTypeBuilder(stmt.argumentAsTypeQName());
+        final var builder = BaseTypes.leafrefTypeBuilder(stmt.argumentAsTypeQName());
 
-        for (final EffectiveStatement<?, ?> subStmt : substatements) {
-            if (subStmt instanceof PathEffectiveStatement) {
-                builder.setPathStatement(((PathEffectiveStatement) subStmt).argument());
-            } else if (subStmt instanceof RequireInstanceEffectiveStatement) {
-                builder.setRequireInstance(((RequireInstanceEffectiveStatement)subStmt).argument());
+        for (var subStmt : substatements) {
+            switch (subStmt) {
+                case PathEffectiveStatement path -> builder.setPathStatement(path.argument());
+                case RequireInstanceEffectiveStatement ries -> builder.setRequireInstance(ries.argument());
+                case null, default -> {
+                    // No-op
+                }
             }
         }
 
@@ -84,7 +85,7 @@ final class LeafrefSpecificationSupport extends AbstractTypeSupport<LeafrefSpeci
 
     private static SourceException noPath(final CommonStmtCtx stmt) {
         /*
-         *  https://tools.ietf.org/html/rfc7950#section-9.12
+         *  https://www.rfc-editor.org/rfc/rfc7950#section-9.12
          *
          *     When the type is "union", the "type" statement (Section 7.4) MUST be
          *     present.