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.model.api.meta.EffectiveStatement;
12 import org.opendaylight.yangtools.yang.model.api.stmt.TypeEffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.LeafrefSpecification;
14 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
15 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
16 import org.opendaylight.yangtools.yang.model.util.type.LeafrefTypeBuilder;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeclaredEffectiveStatementBase;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PathEffectiveStatementImpl;
20 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RequireInstanceEffectiveStatementImpl;
21 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffectiveStatementImpl;
23 public final class LeafrefSpecificationEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, LeafrefSpecification>
24 implements TypeEffectiveStatement<LeafrefSpecification> {
26 private final LeafrefTypeDefinition typeDefinition;
28 public LeafrefSpecificationEffectiveStatementImpl(final StmtContext<String, LeafrefSpecification, EffectiveStatement<String, LeafrefSpecification>> ctx) {
31 final LeafrefTypeBuilder builder = BaseTypes.leafrefTypeBuilder(ctx.getSchemaPath().get());
33 for (final EffectiveStatement<?, ?> stmt : effectiveSubstatements()) {
34 if (stmt instanceof PathEffectiveStatementImpl) {
35 builder.setPathStatement(((PathEffectiveStatementImpl) stmt).argument());
36 } else if(stmt instanceof RequireInstanceEffectiveStatementImpl) {
37 builder.setRequireInstance(((RequireInstanceEffectiveStatementImpl)stmt).argument());
38 } else if (stmt instanceof UnknownEffectiveStatementImpl) {
39 builder.addUnknownSchemaNode((UnknownEffectiveStatementImpl)stmt);
43 typeDefinition = builder.build();
48 public LeafrefTypeDefinition getTypeDefinition() {
49 return typeDefinition;