Bug 2366 - new parser API - implementation of declared statements
[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.Map;
11
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
26 public interface StmtContext<A,D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
27
28     @Nonnull StatementSource getStatementSource();
29
30     @Nonnull StatementSourceReference getStatementSourceReference();
31
32     @Nonnull StatementDefinition getPublicDefinition();
33
34     @Nullable StmtContext<?,?,?> getParentContext();
35
36     @Nullable String rawStatementArgument();
37
38     @Nullable A getStatementArgument();
39
40     //<K,VT, V extends VT,N extends IdentifierNamespace<K, V>>
41     //       <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
42     @Nonnull <K,V,N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, K key) throws NamespaceNotAvailableException;
43
44     <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(Class<N> type);
45
46     @Nonnull StmtContext<?,?,?> getRoot();
47
48     @Nonnull Collection<StatementContextBase<?,?,?>> declaredSubstatements();
49
50     public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
51
52     D buildDeclared();
53
54     E buildEffective();
55
56     public StatementContextBase<?, ?, ?>  createCopy(QNameModule newQNameModule,StatementContextBase<?, ?, ?> newParent) throws SourceException;
57
58     interface Mutable<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>> extends StmtContext<A,D,E> {
59
60         @Override
61         StmtContext.Mutable<?,?,?> getParentContext();
62
63         //<K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value)
64         <K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value) throws NamespaceNotAvailableException;
65
66         @Override
67         StmtContext.Mutable<?,?,?> getRoot();
68
69         ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
70
71         <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(Class<N> namepsace, KT key,
72                 StmtContext<?, ?, ?> stmt);
73
74     }
75
76
77
78 }