ee6007ee292fb264344328c2d3e33bec471d8f9f
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StmtContext.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.spi.meta;
9
10 import java.util.List;
11 import java.util.Map;
12 import org.opendaylight.yangtools.yang.common.QNameModule;
13 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
14 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
15 import java.util.Collection;
16 import javax.annotation.Nonnull;
17 import javax.annotation.Nullable;
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.StatementSourceReference;
24
25 public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
26
27     @Nonnull
28     StatementSource getStatementSource();
29
30     @Nonnull
31     StatementSourceReference getStatementSourceReference();
32
33     @Nonnull
34     StatementDefinition getPublicDefinition();
35
36     @Nullable
37     StmtContext<?, ?, ?> getParentContext();
38
39     @Nullable
40     String rawStatementArgument();
41
42     @Nullable
43     A getStatementArgument();
44
45     @Nullable
46     List<Object> getArgumentsFromRoot();
47
48     List<StmtContext<?,?,?>> getStmtContextsFromRoot();
49
50     @Nonnull
51     <K, V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
52             Class<N> type, KT key) throws NamespaceNotAvailableException;
53
54     <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromNamespace(
55             Class<N> type);
56
57     <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromCurrentStmtCtxNamespace(Class<N> type);
58
59     @Nonnull
60     StmtContext<?, ?, ?> getRoot();
61
62     @Nonnull
63     Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
64
65     Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
66
67     Collection<StatementContextBase<?, ?, ?>> substatements();
68
69     D buildDeclared();
70
71     E buildEffective();
72
73     boolean isSupportedToBuildEffective();
74
75     void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
76
77     Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
78
79     void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
80
81     StatementContextBase<?, ?, ?> createCopy(
82             StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
83             throws SourceException;
84
85     StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
86             StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
87             throws SourceException;
88
89     enum TypeOfCopy {
90         ORIGINAL, ADDED_BY_USES, ADDED_BY_AUGMENTATION, ADDED_BY_USES_AUGMENTATION
91     }
92
93     List<TypeOfCopy> getCopyHistory();
94
95     void addAllToCopyHistory(List<TypeOfCopy> typeOfCopyList);
96
97     void addToCopyHistory(TypeOfCopy typeOfCopy);
98
99     StatementContextBase<?, ?, ?> getOriginalCtx();
100
101     void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
102
103     boolean isRootContext();
104
105     void setOrder(int order);
106
107     int getOrder();
108
109     void setCompletedPhase(ModelProcessingPhase completedPhase);
110
111     ModelProcessingPhase getCompletedPhase();
112
113     interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
114             extends StmtContext<A, D, E> {
115
116         @Override
117         StmtContext.Mutable<?, ?, ?> getParentContext();
118
119         <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
120                 Class<N> type, KT key, VT value)
121                 throws NamespaceNotAvailableException;
122
123         @Override
124         StmtContext.Mutable<?, ?, ?> getRoot();
125
126         ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
127
128         <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
129                 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
130
131     }
132
133 }