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.spi.meta;
10 import com.google.common.base.Optional;
11 import java.util.Collection;
13 import javax.annotation.Nonnull;
14 import javax.annotation.Nullable;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
20 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
21 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
23 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
24 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
26 public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
29 StatementSource getStatementSource();
32 StatementSourceReference getStatementSourceReference();
35 StatementDefinition getPublicDefinition();
38 StmtContext<?, ?, ?> getParentContext();
41 String rawStatementArgument();
44 A getStatementArgument();
47 * Return the {@link SchemaPath} of this statement. Not all statements have a SchemaPath, in which case
48 * {@link Optional#absent()} is returned.
50 * @return Optional SchemaPath
52 @Nonnull Optional<SchemaPath> getSchemaPath();
54 boolean isConfiguration();
56 boolean isEnabledSemanticVersioning();
59 <K, V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
60 Class<N> type, KT key) throws NamespaceNotAvailableException;
62 <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(
65 <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
68 StmtContext<?, ?, ?> getRoot();
71 Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
73 Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
75 Collection<StatementContextBase<?, ?, ?>> substatements();
81 boolean isSupportedToBuildEffective();
83 void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
85 Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
87 void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
89 StatementContextBase<?, ?, ?> createCopy(
90 StatementContextBase<?, ?, ?> newParent, CopyType typeOfCopy)
91 throws SourceException;
93 StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
94 StatementContextBase<?, ?, ?> newParent, CopyType typeOfCopy)
95 throws SourceException;
97 CopyHistory getCopyHistory();
99 enum SupportedByFeatures {
100 UNDEFINED, SUPPORTED, NOT_SUPPORTED
103 SupportedByFeatures getSupportedByFeatures();
105 void appendCopyHistory(CopyType typeOfCopy, CopyHistory toAppend);
107 StatementContextBase<?, ?, ?> getOriginalCtx();
109 void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
111 boolean isRootContext();
113 void setOrder(int order);
117 void setCompletedPhase(ModelProcessingPhase completedPhase);
119 ModelProcessingPhase getCompletedPhase();
121 interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
122 extends StmtContext<A, D, E> {
125 StmtContext.Mutable<?, ?, ?> getParentContext();
127 <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
128 Class<N> type, KT key, VT value)
129 throws NamespaceNotAvailableException;
132 StmtContext.Mutable<?, ?, ?> getRoot();
134 ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
136 <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
137 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
139 void setSupportedByFeatures(boolean isSupported);