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.rfc7950.stmt.type;
10 import org.eclipse.jdt.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.UnknownSchemaNode;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.BaseEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityEffectiveStatement;
17 import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
18 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.IdentityRefSpecification;
20 import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
21 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
22 import org.opendaylight.yangtools.yang.model.util.type.IdentityrefTypeBuilder;
23 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.DeclaredEffectiveStatementBase;
24 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 // FIXME: hide this class
28 public final class IdentityRefSpecificationEffectiveStatement extends
29 DeclaredEffectiveStatementBase<String, IdentityRefSpecification> implements
30 TypeEffectiveStatement<IdentityRefSpecification> {
32 private final @NonNull IdentityrefTypeDefinition typeDefinition;
34 IdentityRefSpecificationEffectiveStatement(final StmtContext<String, IdentityRefSpecification,
35 EffectiveStatement<String, IdentityRefSpecification>> ctx) {
38 final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(ctx.getSchemaPath().get());
39 for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
40 if (stmt instanceof BaseEffectiveStatement) {
41 final QName identityQName = ((BaseEffectiveStatement) stmt).argument();
42 final StmtContext<?, IdentityStatement, IdentityEffectiveStatement> identityCtx =
43 ctx.getFromNamespace(IdentityNamespace.class, identityQName);
44 builder.addIdentity((IdentitySchemaNode) identityCtx.buildEffective());
46 if (stmt instanceof UnknownSchemaNode) {
47 builder.addUnknownSchemaNode((UnknownSchemaNode)stmt);
51 typeDefinition = builder.build();
55 public IdentityrefTypeDefinition getTypeDefinition() {
56 return typeDefinition;