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.reactor;
10 import static java.util.Objects.requireNonNull;
12 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
16 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
18 final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> extends
19 AbstractResumedStatement<A, D, E> {
20 private final StatementContextBase<?, ?, ?> parent;
21 private final A argument;
23 private SubstatementContext(final SubstatementContext<A, D, E> original,
24 final StatementContextBase<?, ?, ?> parent) {
26 this.parent = requireNonNull(parent, "Parent must not be null");
27 this.argument = original.argument;
30 SubstatementContext(final StatementContextBase<?, ?, ?> parent, final StatementDefinitionContext<A, D, E> def,
31 final StatementSourceReference ref, final String rawArgument) {
32 super(def, ref, rawArgument);
33 this.parent = requireNonNull(parent, "Parent must not be null");
34 this.argument = def.parseArgumentValue(this, rawArgument());
37 // FIXME: YANGTOOLS-784: this constructor is only called in contexts where a different implementation
38 // would be more appropriate
39 SubstatementContext(final StatementContextBase<?, ?, ?> parent, final StatementDefinitionContext<A, D, E> def,
40 final StatementSourceReference ref, final String rawArgument, final A argument, final CopyType copyType) {
41 super(def, ref, rawArgument, copyType);
42 this.parent = requireNonNull(parent, "Parent must not be null");
43 this.argument = argument;
47 SubstatementContext<A, D, E> reparent(final StatementContextBase<?, ?, ?> newParent) {
48 return new SubstatementContext<>(this, newParent);
52 * KEEP THINGS ORGANIZED!
54 * below methods exist in the same form in InferredStatementContext. If any adjustment is made here, make sure it is
55 * properly updated there.
63 public StatementContextBase<?, ?, ?> getParentContext() {
68 public StorageNodeType getStorageNodeType() {
69 return StorageNodeType.STATEMENT_LOCAL;
73 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
78 public RootStatementContext<?, ?, ?> getRoot() {
79 return parent.getRoot();
83 public EffectiveConfig effectiveConfig() {
84 return effectiveConfig(parent);
88 protected boolean isIgnoringIfFeatures() {
89 return isIgnoringIfFeatures(parent);
93 protected boolean isIgnoringConfig() {
94 return isIgnoringConfig(parent);
98 protected boolean isParentSupportedByFeatures() {
99 return parent.isSupportedByFeatures();