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;
12 import java.util.List;
14 import javax.annotation.Nonnull;
15 import javax.annotation.Nullable;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
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();
58 <K, V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
59 Class<N> type, KT key) throws NamespaceNotAvailableException;
61 <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(
64 <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
67 StmtContext<?, ?, ?> getRoot();
70 Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
72 Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
74 Collection<StatementContextBase<?, ?, ?>> substatements();
80 boolean isSupportedToBuildEffective();
82 void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
84 Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
86 void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
88 StatementContextBase<?, ?, ?> createCopy(
89 StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
90 throws SourceException;
92 StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
93 StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
94 throws SourceException;
97 ORIGINAL, ADDED_BY_USES, ADDED_BY_AUGMENTATION, ADDED_BY_USES_AUGMENTATION
100 List<TypeOfCopy> getCopyHistory();
102 void addAllToCopyHistory(List<TypeOfCopy> typeOfCopyList);
104 void addToCopyHistory(TypeOfCopy typeOfCopy);
106 StatementContextBase<?, ?, ?> getOriginalCtx();
108 void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
110 boolean isRootContext();
112 void setOrder(int order);
116 void setCompletedPhase(ModelProcessingPhase completedPhase);
118 ModelProcessingPhase getCompletedPhase();
120 interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
121 extends StmtContext<A, D, E> {
124 StmtContext.Mutable<?, ?, ?> getParentContext();
126 <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
127 Class<N> type, KT key, VT value)
128 throws NamespaceNotAvailableException;
131 StmtContext.Mutable<?, ?, ?> getRoot();
133 ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
135 <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
136 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);