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;
10 import com.google.common.base.Verify;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
14 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
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;
28 * context of statement.
30 protected DeclaredEffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
33 this.argument = ctx.getStatementArgument();
34 this.statementSource = ctx.getStatementSource();
37 * Share original instance of declared statement between all effective
38 * statements which have been copied or derived from this original
41 @SuppressWarnings("unchecked")
42 final StmtContext<?, D, ?> lookupCtx = (StmtContext<?, D, ?>) ctx.getOriginalCtx().orElse(ctx);
43 declaredInstance = Verify.verifyNotNull(lookupCtx.buildDeclared(),
44 "Statement %s failed to build declared statement", lookupCtx);
49 public final StatementDefinition statementDefinition() {
50 return declaredInstance.statementDefinition();
60 public final StatementSource getStatementSource() {
61 return statementSource;
65 public final D getDeclared() {
66 return declaredInstance;