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.common.YangVersion;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
21 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
22 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
24 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
25 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
27 public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
30 StatementSource getStatementSource();
33 StatementSourceReference getStatementSourceReference();
36 StatementDefinition getPublicDefinition();
39 StmtContext<?, ?, ?> getParentContext();
42 String rawStatementArgument();
45 A getStatementArgument();
48 * Return the {@link SchemaPath} of this statement. Not all statements have a SchemaPath, in which case
49 * {@link Optional#absent()} is returned.
51 * @return Optional SchemaPath
53 @Nonnull Optional<SchemaPath> getSchemaPath();
55 boolean isConfiguration();
57 boolean isEnabledSemanticVersioning();
60 <K, V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
61 Class<N> type, KT key) throws NamespaceNotAvailableException;
63 <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(
66 <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
69 StmtContext<?, ?, ?> getRoot();
72 * Return declared substatements. These are the statements which are explicitly written in the source model.
74 * @return Collection of declared substatements
77 Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
80 * Return effective substatements. These are the statements which are added as this statement's substatements
81 * complete their effective model phase.
83 * @return Collection of declared substatements
86 Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
92 boolean isSupportedToBuildEffective();
94 void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
96 Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
98 void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
100 void addAsEffectOfStatement(Collection<StatementContextBase<?, ?, ?>> ctxs);
102 StatementContextBase<?, ?, ?> createCopy(
103 StatementContextBase<?, ?, ?> newParent, CopyType typeOfCopy)
104 throws SourceException;
106 StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
107 StatementContextBase<?, ?, ?> newParent, CopyType typeOfCopy)
108 throws SourceException;
110 CopyHistory getCopyHistory();
112 enum SupportedByFeatures {
113 UNDEFINED, SUPPORTED, NOT_SUPPORTED
116 SupportedByFeatures getSupportedByFeatures();
118 void appendCopyHistory(CopyType typeOfCopy, CopyHistory toAppend);
120 StatementContextBase<?, ?, ?> getOriginalCtx();
122 void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
124 boolean isRootContext();
126 void setOrder(int order);
130 void setCompletedPhase(ModelProcessingPhase completedPhase);
132 ModelProcessingPhase getCompletedPhase();
135 * Return version of root statement context.
137 * @return version of root statement context
139 @Nonnull YangVersion getRootVersion();
141 interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
142 extends StmtContext<A, D, E> {
145 StmtContext.Mutable<?, ?, ?> getParentContext();
147 <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
148 Class<N> type, KT key, VT value)
149 throws NamespaceNotAvailableException;
153 StmtContext.Mutable<?, ?, ?> getRoot();
155 ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
157 <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
158 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
160 void setSupportedByFeatures(boolean isSupported);
163 * Set version of root statement context.
166 * of root statement context
168 void setRootVersion(YangVersion version);