Bug 3670 (part 1/5): Use of new statement parser in yang-maven-plugin
[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     D buildDeclared();
68
69     E buildEffective();
70
71     boolean isSupportedToBuildEffective();
72
73     void setIsSupportedToBuildEffective(boolean isSupportedToBuild);
74
75     Collection<StatementContextBase<?, ?, ?>> getEffectOfStatement();
76
77     void addAsEffectOfStatement(StatementContextBase<?, ?, ?> ctx);
78
79     StatementContextBase<?, ?, ?> createCopy(
80             StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
81             throws SourceException;
82
83     StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
84             StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
85             throws SourceException;
86
87     enum TypeOfCopy {
88         ORIGINAL, ADDED_BY_USES, ADDED_BY_AUGMENTATION, ADDED_BY_USES_AUGMENTATION
89     }
90
91     List<TypeOfCopy> getCopyHistory();
92
93     void addAllToCopyHistory(List<TypeOfCopy> typeOfCopyList);
94
95     void addToCopyHistory(TypeOfCopy typeOfCopy);
96
97     StatementContextBase<?, ?, ?> getOriginalCtx();
98
99     void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
100
101     boolean isRootContext();
102
103     void setOrder(int order);
104
105     int getOrder();
106
107     void setCompletedPhase(ModelProcessingPhase completedPhase);
108
109     ModelProcessingPhase getCompletedPhase();
110
111     interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
112             extends StmtContext<A, D, E> {
113
114         @Override
115         StmtContext.Mutable<?, ?, ?> getParentContext();
116
117         <K, V, KT extends K, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
118                 Class<N> type, KT key, VT value)
119                 throws NamespaceNotAvailableException;
120
121         @Override
122         StmtContext.Mutable<?, ?, ?> getRoot();
123
124         ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
125
126         <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
127                 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);
128
129     }
130
131 }