Bug 2366 - Effective statements impl for new yang parser.
[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
12 import java.util.Map;
13 import org.opendaylight.yangtools.yang.common.QNameModule;
14 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
15 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
16 import java.util.Collection;
17 import javax.annotation.Nonnull;
18 import javax.annotation.Nullable;
19 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
20 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
21 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
22 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
23 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
24 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
25
26
27 public interface StmtContext<A,D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
28
29     @Nonnull StatementSource getStatementSource();
30
31     @Nonnull StatementSourceReference getStatementSourceReference();
32
33     @Nonnull StatementDefinition getPublicDefinition();
34
35     @Nullable StmtContext<?,?,?> getParentContext();
36
37     @Nullable String rawStatementArgument();
38
39     @Nullable A getStatementArgument();
40
41     @Nullable List<Object> getArgumentsFromRoot();
42
43     //<K,VT, V extends VT,N extends IdentifierNamespace<K, V>>
44     //       <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
45     @Nonnull <K,V,N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, K key) throws NamespaceNotAvailableException;
46
47     <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(Class<N> type);
48
49     @Nonnull StmtContext<?,?,?> getRoot();
50
51     @Nonnull Collection<StatementContextBase<?,?,?>> declaredSubstatements();
52
53     public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
54
55     D buildDeclared();
56
57     E buildEffective();
58
59     public StatementContextBase<?, ?, ?>  createCopy(QNameModule newQNameModule,StatementContextBase<?, ?, ?> newParent) throws SourceException;
60
61     interface Mutable<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>> extends StmtContext<A,D,E> {
62
63         @Override
64         StmtContext.Mutable<?,?,?> getParentContext();
65
66         //<K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value)
67         <K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value) throws NamespaceNotAvailableException;
68
69         @Override
70         StmtContext.Mutable<?,?,?> getRoot();
71
72         ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
73
74         <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(Class<N> namespace, KT key,
75                 StmtContext<?, ?, ?> stmt);
76
77     }
78
79
80
81 }