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.SchemaPath;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
17 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
19 final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> extends
20 AbstractResumedStatement<A, D, E> {
21 private final StatementContextBase<?, ?, ?> parent;
22 private final A argument;
24 private SubstatementContext(final SubstatementContext<A, D, E> original,
25 final StatementContextBase<?, ?, ?> parent) {
27 this.parent = requireNonNull(parent, "Parent must not be null");
28 this.argument = original.argument;
31 SubstatementContext(final StatementContextBase<?, ?, ?> parent, final StatementDefinitionContext<A, D, E> def,
32 final StatementSourceReference ref, final String rawArgument) {
33 super(def, ref, rawArgument);
34 this.parent = requireNonNull(parent, "Parent must not be null");
35 this.argument = def.parseArgumentValue(this, rawArgument());
38 // FIXME: YANGTOOLS-784: this constructor is only called in contexts where a different implementation
39 // would be more appropriate
40 SubstatementContext(final StatementContextBase<?, ?, ?> parent, final StatementDefinitionContext<A, D, E> def,
41 final StatementSourceReference ref, final String rawArgument, final A argument, final CopyType copyType) {
42 super(def, ref, rawArgument, copyType);
43 this.parent = requireNonNull(parent, "Parent must not be null");
44 this.argument = argument;
48 SubstatementContext<A, D, E> reparent(final StatementContextBase<?, ?, ?> newParent) {
49 return new SubstatementContext<>(this, newParent);
53 * KEEP THINGS ORGANIZED!
55 * below methods exist in the same form in InferredStatementContext. If any adjustment is made here, make sure it is
56 * properly updated there.
60 public SchemaPath schemaPath() {
61 return substatementGetSchemaPath();
70 public StatementContextBase<?, ?, ?> getParentContext() {
75 public StorageNodeType getStorageNodeType() {
76 return StorageNodeType.STATEMENT_LOCAL;
80 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
85 public RootStatementContext<?, ?, ?> getRoot() {
86 return parent.getRoot();
90 public EffectiveConfig effectiveConfig() {
91 return effectiveConfig(parent);
95 protected boolean isIgnoringIfFeatures() {
96 return isIgnoringIfFeatures(parent);
100 protected boolean isIgnoringConfig() {
101 return isIgnoringConfig(parent);
105 protected boolean isParentSupportedByFeatures() {
106 return parent.isSupportedByFeatures();