Split out yang-model-ri
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / type / AbstractIdentityRefSpecificationSupport.java
index 4feb3654e299181053bb90e5ecf4990e6d8c1412..123b6f16a91b7d0c27534df59134ee9b40f81955 100644 (file)
@@ -19,10 +19,10 @@ import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.IdentityRefSpecification;
-import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
-import org.opendaylight.yangtools.yang.model.util.type.IdentityrefTypeBuilder;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+import org.opendaylight.yangtools.yang.model.ri.type.BaseTypes;
+import org.opendaylight.yangtools.yang.model.ri.type.IdentityrefTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.CommonStmtCtx;
 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
@@ -32,15 +32,10 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 abstract class AbstractIdentityRefSpecificationSupport
-        extends BaseStatementSupport<String, IdentityRefSpecification,
+        extends AbstractStringStatementSupport<IdentityRefSpecification,
             EffectiveStatement<String, IdentityRefSpecification>> {
     AbstractIdentityRefSpecificationSupport() {
-        super(YangStmtMapping.TYPE);
-    }
-
-    @Override
-    public final String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return value;
+        super(YangStmtMapping.TYPE, StatementPolicy.exactReplica());
     }
 
     @Override
@@ -51,11 +46,11 @@ abstract class AbstractIdentityRefSpecificationSupport
         final Collection<StmtContext<QName, BaseStatement, ?>> baseStatements =
                 StmtContextUtils.findAllDeclaredSubstatements(stmt, BaseStatement.class);
         for (StmtContext<QName, BaseStatement, ?> baseStmt : baseStatements) {
-            final QName baseIdentity = baseStmt.coerceStatementArgument();
+            final QName baseIdentity = baseStmt.getArgument();
             final StmtContext<?, ?, ?> stmtCtx = stmt.getFromNamespace(IdentityNamespace.class, baseIdentity);
-            InferenceException.throwIfNull(stmtCtx, stmt.sourceReference(),
+            InferenceException.throwIfNull(stmtCtx, stmt,
                 "Referenced base identity '%s' doesn't exist in given scope (module, imported modules, submodules)",
-                    baseIdentity.getLocalName());
+                baseIdentity.getLocalName());
         }
     }
 
@@ -79,7 +74,7 @@ abstract class AbstractIdentityRefSpecificationSupport
             throw noBase(stmt);
         }
 
-        final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(stmt.getSchemaPath());
+        final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(stmt.argumentAsTypeQName());
         for (final EffectiveStatement<?, ?> subStmt : substatements) {
             if (subStmt instanceof BaseEffectiveStatement) {
                 final QName identityQName = ((BaseEffectiveStatement) subStmt).argument();
@@ -100,6 +95,6 @@ abstract class AbstractIdentityRefSpecificationSupport
          *     statement, MUST be present at least once if the type is
          *     "identityref".
          */
-        return new SourceException("At least one base statement has to be present", stmt.sourceReference());
+        return new SourceException("At least one base statement has to be present", stmt);
     }
 }
\ No newline at end of file