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 javax.annotation.Nonnull;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.IdentityRefSpecification;
17 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
18 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
19 import org.opendaylight.yangtools.yang.model.util.type.IdentityrefTypeBuilder;
20 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BaseEffectiveStatementImpl;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase;
24 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementImpl;
26 public final class IdentityRefSpecificationEffectiveStatementImpl extends
27 DeclaredEffectiveStatementBase<String, IdentityRefSpecification> implements
28 TypeEffectiveStatement<IdentityRefSpecification> {
30 private final IdentityrefTypeDefinition typeDefinition;
32 public IdentityRefSpecificationEffectiveStatementImpl(
33 final StmtContext<String, IdentityRefSpecification, EffectiveStatement<String, IdentityRefSpecification>> ctx) {
36 final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(ctx.getSchemaPath().get());
37 for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
38 if (stmt instanceof BaseEffectiveStatementImpl) {
39 final BaseEffectiveStatementImpl base = firstEffective(BaseEffectiveStatementImpl.class);
40 final QName identityQName = base.argument();
41 final StmtContext<?, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> identityCtx =
42 ctx.getFromNamespace(IdentityNamespace.class, identityQName);
43 builder.setIdentity((IdentitySchemaNode) identityCtx.buildEffective());
45 if (stmt instanceof UnknownEffectiveStatementImpl) {
46 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl)stmt);
50 typeDefinition = builder.build();
55 public IdentityrefTypeDefinition getTypeDefinition() {
56 return typeDefinition;