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 java.util.List;
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;
25 public interface StmtContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> {
28 StatementSource getStatementSource();
31 StatementSourceReference getStatementSourceReference();
34 StatementDefinition getPublicDefinition();
37 StmtContext<?, ?, ?> getParentContext();
40 String rawStatementArgument();
43 A getStatementArgument();
46 List<Object> getArgumentsFromRoot();
48 // <K,VT, V extends VT,N extends IdentifierNamespace<K, V>>
49 // <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT
50 // getFromNamespace(Class<N> type, K key)
52 <K, V, N extends IdentifierNamespace<K, V>> V getFromNamespace(
53 Class<N> type, K key) throws NamespaceNotAvailableException;
55 <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(
59 StmtContext<?, ?, ?> getRoot();
62 Collection<StatementContextBase<?, ?, ?>> declaredSubstatements();
64 Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
70 StatementContextBase<?, ?, ?> createCopy(QNameModule newQNameModule,
71 StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy)
72 throws SourceException;
74 public static enum TypeOfCopy {
75 ORIGINAL, ADDED_BY_USES, ADDED_BY_AUGMENTATION
78 TypeOfCopy getTypeOfCopy();
80 void setTypeOfCopy(TypeOfCopy typeOfCopy);
82 StatementContextBase<?, ?, ?> getOriginalCtx();
84 void setOriginalCtx(StatementContextBase<?, ?, ?> originalCtx);
86 boolean isRootContext();
88 void setCompletedPhase(ModelProcessingPhase completedPhase);
90 ModelProcessingPhase getCompletedPhase();
92 interface Mutable<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
93 extends StmtContext<A, D, E> {
96 StmtContext.Mutable<?, ?, ?> getParentContext();
98 // <K,V,VT extends V,N extends IdentifierNamespace<K, V>> void
99 // addToNs(Class<N> type, K key, VT value)
100 <K, V, VT extends V, N extends IdentifierNamespace<K, V>> void addToNs(
101 Class<N> type, K key, VT value)
102 throws NamespaceNotAvailableException;
105 StmtContext.Mutable<?, ?, ?> getRoot();
107 ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
109 <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
110 Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt);