2 * Copyright (c) 2015 Cisco Systems, Inc. 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.stmt.rfc6020.effective.type;
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
12 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.IdentityRefSpecification;
16 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
17 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
18 import org.opendaylight.yangtools.yang.model.util.type.IdentityrefTypeBuilder;
19 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BaseEffectiveStatementImpl;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementImpl;
25 public final class IdentityRefSpecificationEffectiveStatementImpl extends
26 DeclaredEffectiveStatementBase<String, IdentityRefSpecification> implements
27 TypeEffectiveStatement<IdentityRefSpecification> {
29 private final IdentityrefTypeDefinition typeDefinition;
31 public IdentityRefSpecificationEffectiveStatementImpl(
32 final StmtContext<String, IdentityRefSpecification, EffectiveStatement<String, IdentityRefSpecification>> ctx) {
35 final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(ctx.getSchemaPath().get());
36 for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
37 if (stmt instanceof BaseEffectiveStatementImpl) {
38 final BaseEffectiveStatementImpl base = firstEffective(BaseEffectiveStatementImpl.class);
39 final QName identityQName = base.argument();
40 final StmtContext<?, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> identityCtx =
41 ctx.getFromNamespace(IdentityNamespace.class, identityQName);
42 builder.setIdentity((IdentitySchemaNode) identityCtx.buildEffective());
44 if (stmt instanceof UnknownEffectiveStatementImpl) {
45 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl)stmt);
49 typeDefinition = builder.build();
53 public IdentityrefTypeDefinition getTypeDefinition() {
54 return typeDefinition;