Trim down TypeDefinitionAwareCodec
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StatementSupport.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
9 package org.opendaylight.yangtools.yang.parser.spi.meta;
10
11 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
12 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
14 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
15
16 /**
17  *
18  * Support for processing concrete YANG statement.
19  *
20  * This interface is intended to be implemented by developers, which want to
21  * introduce support of statement to parser. Consider subclassing
22  * {@link AbstractStatementSupport} for easier implementation of this interface.
23  *
24  * @param <A>
25  *            Argument type
26  * @param <D>
27  *            Declared Statement representation
28  * @param <E>
29  *            Effective Statement representation
30  */
31 public interface StatementSupport<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> extends
32         StatementDefinition, StatementFactory<A, D, E> {
33
34     /**
35      * Returns public statement definition, which will be present in built
36      * statements.
37      *
38      * Public statement definition may be used to provide different
39      * implementation of statement definition, which will not retain any build
40      * specific data or context.
41      *
42      * @return public statement definition, which will be present in built
43      *         statements.
44      */
45     StatementDefinition getPublicView();
46
47     /**
48      *
49      * Parses textual representation of argument in object representation.
50      *
51      * @param ctx
52      *            Context, which may be used to access source-specific
53      *            namespaces required for parsing.
54      * @param value
55      *            String representation of value, as was present in text source.
56      * @return Parsed value
57      * @throws SourceException when an inconsistency is detected.
58      */
59     A parseArgumentValue(StmtContext<?, ?, ?> ctx, String value);
60
61     /**
62      * Invoked when a statement supported by this instance is added to build context. This allows implementations
63      * of this interface to start tracking the statement and perform any modifications to the build context hierarchy,
64      * accessible via {@link StmtContext#getParentContext()}. One such use is populating the parent's namespaces to
65      * allow it to locate this child statement.
66      *
67      * @param stmt
68      *            Context of added statement. No substatements are available.
69      */
70     void onStatementAdded(StmtContext.Mutable<A, D, E> stmt);
71
72     /**
73      * Invoked when statement is closed during
74      * {@link ModelProcessingPhase#SOURCE_PRE_LINKAGE} phase, only substatements
75      * from this and previous phase are available.
76      *
77      * Implementation may use method to perform actions on this event or
78      * register modification action using
79      * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
80      *
81      * @param stmt
82      *            Context of added statement.
83      */
84     void onPreLinkageDeclared(StmtContext.Mutable<A, D, E> stmt);
85
86     /**
87      * Invoked when statement is closed during
88      * {@link ModelProcessingPhase#SOURCE_LINKAGE} phase, only substatements
89      * from this and previous phase are available.
90      *
91      * Implementation may use method to perform actions on this event or
92      * register modification action using
93      * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
94      *
95      * @param stmt
96      *            Context of added statement.
97      * @throws SourceException when an inconsistency is detected.
98      */
99     void onLinkageDeclared(StmtContext.Mutable<A, D, E> stmt);
100
101     /**
102      * Invoked when statement is closed during
103      * {@link ModelProcessingPhase#STATEMENT_DEFINITION} phase, only
104      * substatements from this phase are available.
105      *
106      * Implementation may use method to perform actions on this event or
107      * register modification action using
108      * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
109      *
110      * @param stmt
111      *            Context of added statement. Argument and statement parent is
112      *            accessible.
113      * @throws SourceException when an inconsistency is detected.
114      */
115     void onStatementDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt);
116
117     /**
118      * Invoked when statement is closed during
119      * {@link ModelProcessingPhase#FULL_DECLARATION} phase.
120      *
121      * Invoked when statement is closed during
122      * {@link ModelProcessingPhase#FULL_DECLARATION} phase, only substatements
123      * from this phase are available.
124      *
125      * Implementation may use method to perform actions on this event or
126      * register modification action using
127      * {@link StmtContext.Mutable#newInferenceAction(ModelProcessingPhase)}.
128      *
129      *
130      * @param stmt
131      *            Context of added statement. Argument and statement parent is
132      *            accessible.
133      * @throws SourceException when an inconsistency is detected.
134      */
135     void onFullDefinitionDeclared(StmtContext.Mutable<A, D, E> stmt);
136 }