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 * Return declared substatements. These are the statements which are explicitly written in the source model.
73 * @return Collection of declared substatements
76 Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
79 * Return effective substatements. These are the statements which are added as this statement's substatements
80 * complete their effective model phase.
82 * @return Collection of declared substatements
85 Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
91 boolean isSupportedToBuildEffective();
93 void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
95 Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
97 void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
99 void addAsEffectOfStatement(Collection<StatementContextBase<?, ?, ?>> ctxs);
101 StatementContextBase<?, ?, ?> createCopy(
102 StatementContextBase<?, ?, ?> newParent, CopyType typeOfCopy)
103 throws SourceException;
105 StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
106 StatementContextBase<?, ?, ?> newParent, CopyType typeOfCopy)
107 throws SourceException;
109 CopyHistory getCopyHistory();
111 enum SupportedByFeatures {
112 UNDEFINED, SUPPORTED, NOT_SUPPORTED
115 SupportedByFeatures getSupportedByFeatures();
117 void appendCopyHistory(CopyType typeOfCopy, CopyHistory toAppend);
119 StatementContextBase<?, ?, ?> getOriginalCtx();
121 void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
123 boolean isRootContext();
125 void setOrder(int order);
129 void setCompletedPhase(ModelProcessingPhase completedPhase);
131 ModelProcessingPhase getCompletedPhase();
133 interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
134 extends StmtContext<A, D, E> {
137 StmtContext.Mutable<?, ?, ?> getParentContext();
139 <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
140 Class<N> type, KT key, VT value)
141 throws NamespaceNotAvailableException;
144 StmtContext.Mutable<?, ?, ?> getRoot();
146 ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
148 <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
149 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
151 void setSupportedByFeatures(boolean isSupported);