Throw SourceException instead of IllegalArgumentException
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / TypeStatementImpl.java
index 992404533e13a5baa4d4ae50b72a86556f09c539..43a37963338b4eb5e823ad81db9cfc4743c22da5 100644 (file)
@@ -33,24 +33,26 @@ import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.TypeDefEffectiveStatementImpl;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BinaryTypeEffectiveStatementImpl;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BitsTypeEffectiveStatementImpl;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BooleanTypeEffectiveStatementImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BuiltinEffectiveStatements;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.BuiltinEffectiveStatement;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.DecimalTypeEffectiveStatementImpl;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.EmptyTypeEffectiveStatementImpl;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.type.EnumTypeEffectiveStatementImpl;
@@ -118,46 +120,46 @@ public class TypeStatementImpl extends AbstractDeclaredStatement<String>
             final TypeEffectiveStatement<TypeStatement> typeStmt;
             switch (ctx.getStatementArgument()) {
                 case TypeUtils.BINARY:
-                    typeStmt = BuiltinEffectiveStatements.BINARY;
+                    typeStmt = BuiltinEffectiveStatement.BINARY;
                     break;
                 case TypeUtils.BOOLEAN:
-                    typeStmt = BuiltinEffectiveStatements.BOOLEAN;
+                    typeStmt = BuiltinEffectiveStatement.BOOLEAN;
                     break;
                 case TypeUtils.EMPTY:
-                    typeStmt = BuiltinEffectiveStatements.EMPTY;
+                    typeStmt = BuiltinEffectiveStatement.EMPTY;
                     break;
                 case TypeUtils.INSTANCE_IDENTIFIER:
-                    typeStmt = BuiltinEffectiveStatements.INSTANCE_IDENTIFIER;
+                    typeStmt = BuiltinEffectiveStatement.INSTANCE_IDENTIFIER;
                     break;
             case TypeUtils.INT8:
-                typeStmt = BuiltinEffectiveStatements.INT8;
+                typeStmt = BuiltinEffectiveStatement.INT8;
                 break;
             case TypeUtils.INT16:
-                typeStmt = BuiltinEffectiveStatements.INT16;
+                typeStmt = BuiltinEffectiveStatement.INT16;
                 break;
             case TypeUtils.INT32:
-                typeStmt = BuiltinEffectiveStatements.INT32;
+                typeStmt = BuiltinEffectiveStatement.INT32;
                 break;
             case TypeUtils.INT64:
-                typeStmt = BuiltinEffectiveStatements.INT64;
+                typeStmt = BuiltinEffectiveStatement.INT64;
                 break;
             case TypeUtils.STRING:
-                typeStmt = BuiltinEffectiveStatements.STRING;
+                typeStmt = BuiltinEffectiveStatement.STRING;
                 break;
             case TypeUtils.UINT8:
-                typeStmt = BuiltinEffectiveStatements.UINT8;
+                typeStmt = BuiltinEffectiveStatement.UINT8;
                 break;
             case TypeUtils.UINT16:
-                typeStmt = BuiltinEffectiveStatements.UINT16;
+                typeStmt = BuiltinEffectiveStatement.UINT16;
                 break;
             case TypeUtils.UINT32:
-                typeStmt = BuiltinEffectiveStatements.UINT32;
+                typeStmt = BuiltinEffectiveStatement.UINT32;
                 break;
             case TypeUtils.UINT64:
-                typeStmt = BuiltinEffectiveStatements.UINT64;
+                typeStmt = BuiltinEffectiveStatement.UINT64;
                 break;
             default:
-                final QName qname = Utils.qNameFromArgument(ctx, ctx.getStatementArgument());
+                final QName qname = StmtContextUtils.qnameFromArgument(ctx, ctx.getStatementArgument());
                 final StmtContext<?, TypedefStatement, TypedefEffectiveStatement> typedef =
                         ctx.getFromNamespace(TypeNamespace.class, qname);
                 SourceException.throwIfNull(typedef, ctx.getStatementSourceReference(), "Type '%s' not found", qname);
@@ -214,7 +216,7 @@ public class TypeStatementImpl extends AbstractDeclaredStatement<String>
                 return;
             }
 
-            final QName typeQName = Utils.qNameFromArgument(stmt, stmt.getStatementArgument());
+            final QName typeQName = StmtContextUtils.qnameFromArgument(stmt, stmt.getStatementArgument());
             final ModelActionBuilder typeAction = stmt.newInferenceAction(ModelProcessingPhase.EFFECTIVE_MODEL);
             final Prerequisite<StmtContext<?, ?, ?>> typePrereq = typeAction.requiresCtx(stmt, TypeNamespace.class,
                     typeQName, ModelProcessingPhase.EFFECTIVE_MODEL);
@@ -226,7 +228,7 @@ public class TypeStatementImpl extends AbstractDeclaredStatement<String>
              */
             typeAction.apply(new InferenceAction() {
                 @Override
-                public void apply() {
+                public void apply(final InferenceContext ctx) {
                     // Intentional NOOP
                 }