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;
10 import com.google.common.base.Verify;
11 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
12 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
13 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
15 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
17 public abstract class DeclaredEffectiveStatementBase<A, D extends DeclaredStatement<A>> extends
18 EffectiveStatementBase<A, D> {
20 private final StatementSource statementSource;
21 private final A argument;
22 private final D declaredInstance;
24 public DeclaredEffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
32 * context of statement.
33 * @param buildUnknownSubstatements
34 * if it is false, the unknown substatements are omitted from
35 * build of effective substatements till the call of either
36 * effectiveSubstatements or getOmittedUnknownSubstatements
37 * method of EffectiveStatementBase class. The main purpose of
38 * this is to allow the build of recursive extension definitions.
40 protected DeclaredEffectiveStatementBase(StmtContext<A, D, ?> ctx, final boolean buildUnknownSubstatements) {
41 super(ctx, buildUnknownSubstatements);
43 this.argument = ctx.getStatementArgument();
44 this.statementSource = ctx.getStatementSource();
47 * Share original instance of declared statement between all effective
48 * statements which have been copied or derived from this original
51 StatementContextBase<A, D, ?> originalCtx = (StatementContextBase<A, D, ?>) ctx.getOriginalCtx();
52 if (originalCtx != null) {
55 declaredInstance = Verify.verifyNotNull(ctx.buildDeclared(), "Statement %s failed to build declared statement",
60 public final StatementDefinition statementDefinition() {
61 return declaredInstance.statementDefinition();
70 public final StatementSource getStatementSource() {
71 return statementSource;
75 public final D getDeclared() {
76 return declaredInstance;