2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type;
10 import java.util.Collection;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.IdentityRefSpecification;
16 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
23 abstract class AbstractIdentityRefSpecificationSupport
24 extends AbstractStatementSupport<String, IdentityRefSpecification,
25 EffectiveStatement<String, IdentityRefSpecification>> {
26 AbstractIdentityRefSpecificationSupport() {
27 super(YangStmtMapping.TYPE);
31 public final String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
36 public final IdentityRefSpecification createDeclared(final StmtContext<String, IdentityRefSpecification, ?> ctx) {
37 return new IdentityRefSpecificationImpl(ctx);
41 public final EffectiveStatement<String, IdentityRefSpecification> createEffective(
42 final StmtContext<String, IdentityRefSpecification,
43 EffectiveStatement<String, IdentityRefSpecification>> ctx) {
44 return new IdentityRefSpecificationEffectiveStatement(ctx);
48 public final void onFullDefinitionDeclared(final Mutable<String, IdentityRefSpecification,
49 EffectiveStatement<String, IdentityRefSpecification>> stmt) {
50 super.onFullDefinitionDeclared(stmt);
52 final Collection<StmtContext<QName, BaseStatement, ?>> baseStatements =
53 StmtContextUtils.findAllDeclaredSubstatements(stmt, BaseStatement.class);
54 for (StmtContext<QName, BaseStatement, ?> baseStmt : baseStatements) {
55 final QName baseIdentity = baseStmt.getStatementArgument();
56 final StmtContext<?, ?, ?> stmtCtx = stmt.getFromNamespace(IdentityNamespace.class, baseIdentity);
57 InferenceException.throwIfNull(stmtCtx, stmt.getStatementSourceReference(),
58 "Referenced base identity '%s' doesn't exist in given scope (module, imported modules, submodules)",
59 baseIdentity.getLocalName());