Define a feature-parent
[yangtools.git] / parser / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / reactor / RFC7950Reactors.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.rfc7950.reactor;
9
10 import static org.opendaylight.yangtools.yang.common.YangVersion.VERSION_1;
11 import static org.opendaylight.yangtools.yang.common.YangVersion.VERSION_1_1;
12
13 import com.google.common.annotations.Beta;
14 import com.google.common.collect.ImmutableSet;
15 import com.google.common.collect.Sets;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.common.YangVersion;
18 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
19 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.ModuleQNameToPrefix;
20 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.YangNamespaceContextNamespace;
21 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.augment.AugmentImplicitHandlingNamespace;
22 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.augment.AugmentStatementRFC6020Support;
23 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.augment.AugmentStatementRFC7950Support;
24 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.deviate.DeviateStatementRFC6020Support;
25 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.deviate.DeviateStatementRFC7950Support;
26 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.extension.ExtensionStatementSupport;
27 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureStatementRFC6020Support;
28 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureStatementRFC7950Support;
29 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_.ImportStatementSupport;
30 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_.ImportedVersionNamespace;
31 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.list.ConfigListWarningNamespace;
32 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.list.ListStatementSupport;
33 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ActionStatementSupport;
34 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.AnydataStatementSupport;
35 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.AnyxmlStatementSupport;
36 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ArgumentStatementSupport;
37 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.BaseStatementSupport;
38 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.BelongsToStatementSupport;
39 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.BitStatementSupport;
40 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.CaseStatementSupport;
41 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ChoiceStatementSupport;
42 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ConfigStatementSupport;
43 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ContactStatementSupport;
44 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ContainerStatementSupport;
45 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.DefaultStatementSupport;
46 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.DescriptionStatementSupport;
47 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.DeviationStatementSupport;
48 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.EnumStatementSupport;
49 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ErrorAppTagStatementSupport;
50 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ErrorMessageStatementSupport;
51 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.FeatureStatementSupport;
52 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.FractionDigitsStatementSupport;
53 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.GroupingStatementSupport;
54 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.IdentityStatementSupport;
55 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.IncludeStatementSupport;
56 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.InputStatementSupport;
57 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.KeyStatementSupport;
58 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.LeafListStatementSupport;
59 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.LeafStatementSupport;
60 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.LengthStatementSupport;
61 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.MandatoryStatementSupport;
62 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.MaxElementsStatementSupport;
63 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.MinElementsStatementSupport;
64 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ModifierStatementSupport;
65 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.MustStatementSupport;
66 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.NamespaceStatementSupport;
67 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.OrderedByStatementSupport;
68 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.OrganizationStatementSupport;
69 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.OutputStatementSupport;
70 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.PositionStatementSupport;
71 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.PrefixStatementSupport;
72 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.PresenceStatementSupport;
73 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RangeStatementSupport;
74 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ReferenceStatementSupport;
75 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RefineStatementSupport;
76 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RequireInstanceStatementSupport;
77 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RevisionDateStatementSupport;
78 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RevisionStatementSupport;
79 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RpcStatementSupport;
80 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.StatusStatementSupport;
81 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.TypedefStatementSupport;
82 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.UniqueStatementSupport;
83 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.UnitsStatementSupport;
84 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ValueStatementSupport;
85 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.WhenStatementSupport;
86 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.XPathSupport;
87 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.YangVersionStatementSupport;
88 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.YinElementStatementSupport;
89 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.module.ModuleStatementSupport;
90 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.module.QNameModuleNamespace;
91 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification.NotificationStatementRFC6020Support;
92 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification.NotificationStatementRFC7950Support;
93 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.path.PathStatementSupport;
94 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.pattern.PatternStatementSupport;
95 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.submodule.SubmoduleStatementSupport;
96 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type.BaseTypeNamespace;
97 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type.TypeStatementRFC6020Support;
98 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type.TypeStatementRFC7950Support;
99 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.uses.SourceGroupingNamespace;
100 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.uses.UsesStatementSupport;
101 import org.opendaylight.yangtools.yang.parser.spi.NamespaceBehaviours;
102 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
103 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementDefinitions;
104 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
105 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundles;
106 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundles.ValidationBundleType;
107 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
108 import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
109
110 /**
111  * Utility class holding entrypoints for assembling RFC6020/RFC7950 statement {@link CrossSourceStatementReactor}s.
112  *
113  * @author Robert Varga
114  */
115 @Beta
116 public final class RFC7950Reactors {
117     private static final ImmutableSet<YangVersion> SUPPORTED_VERSIONS = Sets.immutableEnumSet(VERSION_1, VERSION_1_1);
118
119     private static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle.builder(SUPPORTED_VERSIONS)
120         .addSupport(ValidationBundles.BEHAVIOUR)
121         .addSupport(NamespaceBehaviours.SUPPORTED_FEATURES)
122         .addSupport(NamespaceBehaviours.MODULES_DEVIATED_BY)
123         .build();
124
125     private RFC7950Reactors() {
126         // Hidden on purpose
127     }
128
129     private static StatementSupportBundle preLinkageBundle(final YangParserConfiguration config) {
130         return StatementSupportBundle.derivedFrom(INIT_BUNDLE)
131             .addVersionSpecificSupport(VERSION_1, ModuleStatementSupport.rfc6020Instance(config))
132             .addVersionSpecificSupport(VERSION_1_1, ModuleStatementSupport.rfc7950Instance(config))
133             .addVersionSpecificSupport(VERSION_1, SubmoduleStatementSupport.rfc6020Instance(config))
134             .addVersionSpecificSupport(VERSION_1_1, SubmoduleStatementSupport.rfc7950Instance(config))
135             .addSupport(new NamespaceStatementSupport(config))
136             .addVersionSpecificSupport(VERSION_1, ImportStatementSupport.rfc6020Instance(config))
137             .addVersionSpecificSupport(VERSION_1_1, ImportStatementSupport.rfc7950Instance(config))
138             .addVersionSpecificSupport(VERSION_1, IncludeStatementSupport.rfc6020Instance(config))
139             .addVersionSpecificSupport(VERSION_1_1, IncludeStatementSupport.rfc7950Instance(config))
140             .addSupport(new BelongsToStatementSupport(config))
141             .addSupport(new PrefixStatementSupport(config))
142             .addSupport(new YangVersionStatementSupport(config))
143             .addSupport(new RevisionStatementSupport(config))
144             .addSupport(new RevisionDateStatementSupport(config))
145             .addSupport(NamespaceBehaviours.MODULE_NAME_TO_NAMESPACE)
146             .addSupport(NamespaceBehaviours.PRELINKAGE_MODULE)
147             .addSupport(NamespaceBehaviours.IMP_PREFIX_TO_NAMESPACE)
148             .addSupport(NamespaceBehaviours.MODULECTX_TO_QNAME)
149             .addSupport(QNameModuleNamespace.BEHAVIOUR)
150             .addSupport(ImportedVersionNamespace.BEHAVIOUR)
151             .build();
152     }
153
154     private static StatementSupportBundle linkageBundle(final StatementSupportBundle preLinkageBundle,
155             final YangParserConfiguration config) {
156         return StatementSupportBundle.derivedFrom(preLinkageBundle)
157             .addSupport(new DescriptionStatementSupport(config))
158             .addSupport(new ReferenceStatementSupport(config))
159             .addSupport(new ContactStatementSupport(config))
160             .addSupport(new OrganizationStatementSupport(config))
161             .addSupport(NamespaceBehaviours.MODULE)
162             .addSupport(NamespaceBehaviours.MODULE_FOR_BELONGSTO)
163             .addSupport(NamespaceBehaviours.SUBMODULE)
164             .addSupport(NamespaceBehaviours.NAMESPACE_TO_MODULE)
165             .addSupport(NamespaceBehaviours.MODULE_NAME_TO_QNAME)
166             .addSupport(NamespaceBehaviours.MODULECTX_TO_SOURCE)
167             .addSupport(NamespaceBehaviours.MODULE_NAMESPACE_TO_NAME)
168             .addSupport(NamespaceBehaviours.PREFIX_TO_MODULE)
169             .addSupport(NamespaceBehaviours.IMPORTED_MODULE)
170             .addSupport(NamespaceBehaviours.INCLUDED_MODULE)
171             .addSupport(NamespaceBehaviours.INCLUDED_SUBMODULE_NAME_TO_MODULECTX)
172             .addSupport(NamespaceBehaviours.IMPORT_PREFIX_TO_MODULECTX)
173             .addSupport(NamespaceBehaviours.BELONGSTO_PREFIX_TO_MODULECTX)
174             .addSupport(ModuleQNameToPrefix.BEHAVIOUR)
175             .addSupport(NamespaceBehaviours.BELONGSTO_PREFIX_TO_MODULE_NAME)
176             .build();
177     }
178
179     private static StatementSupportBundle stmtDefBundle(final StatementSupportBundle linkageBundle,
180             final YangParserConfiguration config) {
181         return StatementSupportBundle.derivedFrom(linkageBundle)
182             .addSupport(new YinElementStatementSupport(config))
183             .addSupport(new ArgumentStatementSupport(config))
184             .addSupport(new ExtensionStatementSupport(config))
185             .addSupport(NamespaceBehaviours.SCHEMA_TREE)
186             .addSupport(NamespaceBehaviours.EXTENSION)
187             .addSupport(new TypedefStatementSupport(config))
188             .addSupport(NamespaceBehaviours.TYPE)
189             .addVersionSpecificSupport(VERSION_1, IdentityStatementSupport.rfc6020Instance(config))
190             .addVersionSpecificSupport(VERSION_1_1, IdentityStatementSupport.rfc7950Instance(config))
191             .addSupport(NamespaceBehaviours.IDENTITY)
192             .addSupport(new DefaultStatementSupport(config))
193             .addSupport(new StatusStatementSupport(config))
194             .addSupport(BaseTypeNamespace.BEHAVIOUR)
195             .addVersionSpecificSupport(VERSION_1, new TypeStatementRFC6020Support(config))
196             .addVersionSpecificSupport(VERSION_1_1, new TypeStatementRFC7950Support(config))
197             .addSupport(new UnitsStatementSupport(config))
198             .addSupport(new RequireInstanceStatementSupport(config))
199             .addVersionSpecificSupport(VERSION_1, BitStatementSupport.rfc6020Instance(config))
200             .addVersionSpecificSupport(VERSION_1_1, BitStatementSupport.rfc7950Instance(config))
201             .addSupport(PathStatementSupport.strictInstance(config))
202             .addVersionSpecificSupport(VERSION_1, EnumStatementSupport.rfc6020Instance(config))
203             .addVersionSpecificSupport(VERSION_1_1, EnumStatementSupport.rfc7950Instance(config))
204             .addSupport(new LengthStatementSupport(config))
205             .addVersionSpecificSupport(VERSION_1, PatternStatementSupport.rfc6020Instance(config))
206             .addVersionSpecificSupport(VERSION_1_1, PatternStatementSupport.rfc7950Instance(config))
207             .addVersionSpecificSupport(VERSION_1_1, new ModifierStatementSupport(config))
208             .addSupport(new RangeStatementSupport(config))
209             .addSupport(new KeyStatementSupport(config))
210             .addVersionSpecificSupport(VERSION_1, ContainerStatementSupport.rfc6020Instance(config))
211             .addVersionSpecificSupport(VERSION_1_1, ContainerStatementSupport.rfc7950Instance(config))
212             .addVersionSpecificSupport(VERSION_1, GroupingStatementSupport.rfc6020Instance(config))
213             .addVersionSpecificSupport(VERSION_1_1, GroupingStatementSupport.rfc7950Instance(config))
214             .addVersionSpecificSupport(VERSION_1, ListStatementSupport.rfc6020Instance(config))
215             .addVersionSpecificSupport(VERSION_1_1, ListStatementSupport.rfc7950Instance(config))
216             .addSupport(ConfigListWarningNamespace.BEHAVIOUR)
217             .addSupport(new UniqueStatementSupport(config))
218             .addVersionSpecificSupport(VERSION_1_1, new ActionStatementSupport(config))
219             .addVersionSpecificSupport(VERSION_1, new RpcStatementSupport(config))
220             .addVersionSpecificSupport(VERSION_1_1, new RpcStatementSupport(config))
221             .addVersionSpecificSupport(VERSION_1, InputStatementSupport.rfc6020Instance(config))
222             .addVersionSpecificSupport(VERSION_1_1, InputStatementSupport.rfc7950Instance(config))
223             .addVersionSpecificSupport(VERSION_1, OutputStatementSupport.rfc6020Instance(config))
224             .addVersionSpecificSupport(VERSION_1_1, OutputStatementSupport.rfc7950Instance(config))
225             .addVersionSpecificSupport(VERSION_1, new NotificationStatementRFC6020Support(config))
226             .addVersionSpecificSupport(VERSION_1_1, new NotificationStatementRFC7950Support(config))
227             .addSupport(new FractionDigitsStatementSupport(config))
228             .addSupport(new BaseStatementSupport(config))
229             .addSupport(StatementDefinitions.BEHAVIOUR)
230             .build();
231     }
232
233     /**
234      * Returns a pre-built {@link CrossSourceStatementReactor} supporting RFC6020 and RFC7950, along with OpenConfig
235      * semantic version extension. This is useful for parsing near-vanilla YANG models while providing complete
236      * support for semantic versions.
237      *
238      * @return A shared reactor instance.
239      */
240     public static @NonNull CrossSourceStatementReactor defaultReactor() {
241         return ServiceLoaderState.DefaultReactor.INSTANCE;
242     }
243
244     /**
245      * Returns a partially-configured {@link CustomCrossSourceStatementReactorBuilder}, with RFC6020/RFC7950
246      * and OpenConfig semantic version support enabled.
247      *
248      * @return A new {@link CustomCrossSourceStatementReactorBuilder}.
249      */
250     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder() {
251         return defaultReactorBuilder(YangParserConfiguration.DEFAULT);
252     }
253
254     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
255             final YangParserConfiguration config) {
256         return vanillaReactorBuilder(config);
257     }
258
259     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
260             final YangXPathParserFactory xpathFactory) {
261         return defaultReactorBuilder(xpathFactory, YangParserConfiguration.DEFAULT);
262     }
263
264     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
265             final YangXPathParserFactory xpathFactory, final YangParserConfiguration config) {
266         return vanillaReactorBuilder(xpathFactory, config);
267     }
268
269     /**
270      * Returns a pre-built {@link CrossSourceStatementReactor} supporting both RFC6020 and RFC7950. This is useful
271      * for parsing vanilla YANG models without any semantic support for extensions. Notably missing is the semantic
272      * version extension, hence attempts to use semantic version mode will cause failures.
273      *
274      * @return A shared reactor instance.
275      */
276     public static @NonNull CrossSourceStatementReactor vanillaReactor() {
277         return ServiceLoaderState.VanillaReactor.INSTANCE;
278     }
279
280     /**
281      * Returns a partially-configured {@link CustomCrossSourceStatementReactorBuilder}, with vanilla RFC6020/RFC7950
282      * support enabled.
283      *
284      * @return A new {@link CustomCrossSourceStatementReactorBuilder}.
285      */
286     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder() {
287         return vanillaReactorBuilder(YangParserConfiguration.DEFAULT);
288     }
289
290     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
291             final YangParserConfiguration config) {
292         return vanillaReactorBuilder(ServiceLoaderState.XPath.INSTANCE, config);
293     }
294
295     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
296             final @NonNull YangXPathParserFactory xpathFactory) {
297         return vanillaReactorBuilder(xpathFactory, YangParserConfiguration.DEFAULT);
298     }
299
300     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
301             final @NonNull YangXPathParserFactory xpathFactory, final YangParserConfiguration config) {
302         return vanillaReactorBuilder(new XPathSupport(xpathFactory), config);
303     }
304
305     private static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
306             final @NonNull XPathSupport xpathSupport, final YangParserConfiguration config) {
307         final StatementSupportBundle preLinkageBundle = preLinkageBundle(config);
308         final StatementSupportBundle linkageBundle = linkageBundle(preLinkageBundle, config);
309         final StatementSupportBundle stmtDefBundle = stmtDefBundle(linkageBundle, config);
310         final StatementSupportBundle fullDeclarationBundle =
311             fullDeclarationBundle(stmtDefBundle, xpathSupport, config);
312
313         return new CustomCrossSourceStatementReactorBuilder(SUPPORTED_VERSIONS)
314                 .addAllSupports(ModelProcessingPhase.INIT, INIT_BUNDLE)
315                 .addAllSupports(ModelProcessingPhase.SOURCE_PRE_LINKAGE, preLinkageBundle)
316                 .addAllSupports(ModelProcessingPhase.SOURCE_LINKAGE, linkageBundle)
317                 .addAllSupports(ModelProcessingPhase.STATEMENT_DEFINITION, stmtDefBundle)
318                 .addAllSupports(ModelProcessingPhase.FULL_DECLARATION, fullDeclarationBundle)
319                 .addAllSupports(ModelProcessingPhase.EFFECTIVE_MODEL, fullDeclarationBundle)
320                 .addValidationBundle(ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS,
321                     YangValidationBundles.SUPPORTED_REFINE_SUBSTATEMENTS)
322                 .addValidationBundle(ValidationBundleType.SUPPORTED_AUGMENT_TARGETS,
323                     YangValidationBundles.SUPPORTED_AUGMENT_TARGETS)
324
325                 // FIXME: 7.0.0: we do not seem to need this validation bundle
326                 .addValidationBundle(ValidationBundleType.SUPPORTED_CASE_SHORTHANDS,
327                     YangValidationBundles.SUPPORTED_CASE_SHORTHANDS)
328
329                 .addValidationBundle(ValidationBundleType.SUPPORTED_DATA_NODES,
330                     YangValidationBundles.SUPPORTED_DATA_NODES);
331     }
332
333     private static @NonNull StatementSupportBundle fullDeclarationBundle(final StatementSupportBundle stmtDefBundle,
334             final XPathSupport xpathSupport, final YangParserConfiguration config) {
335         return StatementSupportBundle.derivedFrom(stmtDefBundle)
336             .addSupport(new LeafStatementSupport(config))
337             .addSupport(new ConfigStatementSupport(config))
338             .addSupport(new DeviationStatementSupport(config))
339             .addVersionSpecificSupport(VERSION_1, new DeviateStatementRFC6020Support(config))
340             .addVersionSpecificSupport(VERSION_1_1, new DeviateStatementRFC7950Support(config))
341             .addVersionSpecificSupport(VERSION_1, ChoiceStatementSupport.rfc6020Instance(config))
342             .addVersionSpecificSupport(VERSION_1_1, ChoiceStatementSupport.rfc7950Instance(config))
343             .addVersionSpecificSupport(VERSION_1, CaseStatementSupport.rfc6020Instance(config))
344             .addVersionSpecificSupport(VERSION_1_1, CaseStatementSupport.rfc7950Instance(config))
345             .addSupport(new MustStatementSupport(xpathSupport, config))
346             .addSupport(new MandatoryStatementSupport(config))
347             .addSupport(new AnyxmlStatementSupport(config))
348             .addVersionSpecificSupport(VERSION_1_1, new AnydataStatementSupport(config))
349             .addSupport(NamespaceBehaviours.FEATURE)
350             .addVersionSpecificSupport(VERSION_1, new IfFeatureStatementRFC6020Support(config))
351             .addVersionSpecificSupport(VERSION_1_1, new IfFeatureStatementRFC7950Support(config))
352             .addSupport(NamespaceBehaviours.GROUPING)
353             .addSupport(SourceGroupingNamespace.BEHAVIOUR)
354             .addSupport(new UsesStatementSupport(config))
355             .addSupport(new ErrorMessageStatementSupport(config))
356             .addSupport(new ErrorAppTagStatementSupport(config))
357             .addVersionSpecificSupport(VERSION_1, LeafListStatementSupport.rfc6020Instance(config))
358             .addVersionSpecificSupport(VERSION_1_1, LeafListStatementSupport.rfc7950Instance(config))
359             .addSupport(new PresenceStatementSupport(config))
360             .addSupport(new MaxElementsStatementSupport(config))
361             .addSupport(new MinElementsStatementSupport(config))
362             .addSupport(new OrderedByStatementSupport(config))
363             .addSupport(new WhenStatementSupport(xpathSupport, config))
364             .addSupport(AugmentImplicitHandlingNamespace.BEHAVIOUR)
365             .addVersionSpecificSupport(VERSION_1, new AugmentStatementRFC6020Support(config))
366             .addVersionSpecificSupport(VERSION_1_1, new AugmentStatementRFC7950Support(config))
367             .addVersionSpecificSupport(VERSION_1, RefineStatementSupport.rfc6020Instance(config))
368             .addVersionSpecificSupport(VERSION_1_1, RefineStatementSupport.rfc7950Instance(config))
369             .addSupport(new FeatureStatementSupport(config))
370             .addSupport(new PositionStatementSupport(config))
371             .addSupport(new ValueStatementSupport(config))
372             .addSupport(YangNamespaceContextNamespace.BEHAVIOUR)
373             .build();
374     }
375 }