Remove BelongsToModuleContext
[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.RequireInstanceStatementSupport;
76 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RevisionDateStatementSupport;
77 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RevisionStatementSupport;
78 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.RpcStatementSupport;
79 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.StatusStatementSupport;
80 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.TypedefStatementSupport;
81 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.UniqueStatementSupport;
82 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.UnitsStatementSupport;
83 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ValueStatementSupport;
84 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.WhenStatementSupport;
85 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.XPathSupport;
86 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.YangVersionStatementSupport;
87 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.YinElementStatementSupport;
88 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.module.ModuleStatementSupport;
89 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.module.QNameModuleNamespace;
90 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification.NotificationStatementRFC6020Support;
91 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.notification.NotificationStatementRFC7950Support;
92 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.path.PathStatementSupport;
93 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.pattern.PatternStatementSupport;
94 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.refine.RefineStatementSupport;
95 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.refine.RefineTargetNamespace;
96 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.submodule.SubmoduleStatementSupport;
97 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type.BaseTypeNamespace;
98 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type.TypeStatementRFC6020Support;
99 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.type.TypeStatementRFC7950Support;
100 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.uses.SourceGroupingNamespace;
101 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.uses.UsesStatementSupport;
102 import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
103 import org.opendaylight.yangtools.yang.parser.spi.FeatureNamespace;
104 import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
105 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
106 import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
107 import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
108 import org.opendaylight.yangtools.yang.parser.spi.PreLinkageModuleNamespace;
109 import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
110 import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
111 import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
112 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
113 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementDefinitionNamespace;
114 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
115 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleCtx;
116 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
117 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
118 import org.opendaylight.yangtools.yang.parser.spi.source.ImportPrefixToModuleCtx;
119 import org.opendaylight.yangtools.yang.parser.spi.source.ImportedModuleContext;
120 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedModuleContext;
121 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToModuleCtx;
122 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
123 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToSourceIdentifier;
124 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
125 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToNamespace;
126 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
127 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
128 import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules;
129 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
130 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
131 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
132 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
133 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
134 import org.opendaylight.yangtools.yang.xpath.api.YangXPathParserFactory;
135
136 /**
137  * Utility class holding entrypoints for assembling RFC6020/RFC7950 statement {@link CrossSourceStatementReactor}s.
138  *
139  * @author Robert Varga
140  */
141 @Beta
142 public final class RFC7950Reactors {
143     private static final ImmutableSet<YangVersion> SUPPORTED_VERSIONS = Sets.immutableEnumSet(VERSION_1, VERSION_1_1);
144
145     private static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle.builder(SUPPORTED_VERSIONS)
146         .addSupport(ValidationBundlesNamespace.BEHAVIOUR)
147         .addSupport(SupportedFeaturesNamespace.BEHAVIOUR)
148         .addSupport(ModulesDeviatedByModules.BEHAVIOUR)
149         .build();
150
151     private RFC7950Reactors() {
152         // Hidden on purpose
153     }
154
155     private static StatementSupportBundle preLinkageBundle(final YangParserConfiguration config) {
156         return StatementSupportBundle.derivedFrom(INIT_BUNDLE)
157             .addVersionSpecificSupport(VERSION_1, ModuleStatementSupport.rfc6020Instance(config))
158             .addVersionSpecificSupport(VERSION_1_1, ModuleStatementSupport.rfc7950Instance(config))
159             .addVersionSpecificSupport(VERSION_1, SubmoduleStatementSupport.rfc6020Instance(config))
160             .addVersionSpecificSupport(VERSION_1_1, SubmoduleStatementSupport.rfc7950Instance(config))
161             .addSupport(new NamespaceStatementSupport(config))
162             .addVersionSpecificSupport(VERSION_1, ImportStatementSupport.rfc6020Instance(config))
163             .addVersionSpecificSupport(VERSION_1_1, ImportStatementSupport.rfc7950Instance(config))
164             .addVersionSpecificSupport(VERSION_1, IncludeStatementSupport.rfc6020Instance(config))
165             .addVersionSpecificSupport(VERSION_1_1, IncludeStatementSupport.rfc7950Instance(config))
166             .addSupport(new BelongsToStatementSupport(config))
167             .addSupport(new PrefixStatementSupport(config))
168             .addSupport(new YangVersionStatementSupport(config))
169             .addSupport(new RevisionStatementSupport(config))
170             .addSupport(new RevisionDateStatementSupport(config))
171             .addSupport(ModuleNameToNamespace.BEHAVIOUR)
172             .addSupport(PreLinkageModuleNamespace.BEHAVIOUR)
173             .addSupport(ImpPrefixToNamespace.BEHAVIOUR)
174             .addSupport(ModuleCtxToModuleQName.BEHAVIOUR)
175             .addSupport(QNameModuleNamespace.BEHAVIOUR)
176             .addSupport(ImportedVersionNamespace.BEHAVIOUR)
177             .build();
178     }
179
180     private static StatementSupportBundle linkageBundle(final StatementSupportBundle preLinkageBundle,
181             final YangParserConfiguration config) {
182         return StatementSupportBundle.derivedFrom(preLinkageBundle)
183             .addSupport(new DescriptionStatementSupport(config))
184             .addSupport(new ReferenceStatementSupport(config))
185             .addSupport(new ContactStatementSupport(config))
186             .addSupport(new OrganizationStatementSupport(config))
187             .addSupport(ModuleNamespace.BEHAVIOUR)
188             .addSupport(ModuleNamespaceForBelongsTo.BEHAVIOUR)
189             .addSupport(SubmoduleNamespace.BEHAVIOUR)
190             .addSupport(NamespaceToModule.BEHAVIOUR)
191             .addSupport(ModuleNameToModuleQName.BEHAVIOUR)
192             .addSupport(ModuleCtxToSourceIdentifier.BEHAVIOUR)
193             .addSupport(ModuleQNameToModuleName.BEHAVIOUR)
194             .addSupport(PrefixToModule.BEHAVIOUR)
195             .addSupport(ImportedModuleContext.BEHAVIOUR)
196             .addSupport(IncludedModuleContext.BEHAVIOUR)
197             .addSupport(IncludedSubmoduleNameToModuleCtx.BEHAVIOUR)
198             .addSupport(ImportPrefixToModuleCtx.BEHAVIOUR)
199             .addSupport(BelongsToPrefixToModuleCtx.BEHAVIOUR)
200             .addSupport(ModuleQNameToPrefix.BEHAVIOUR)
201             .addSupport(BelongsToPrefixToModuleName.BEHAVIOUR)
202             .build();
203     }
204
205     private static StatementSupportBundle stmtDefBundle(final StatementSupportBundle linkageBundle,
206             final YangParserConfiguration config) {
207         return StatementSupportBundle.derivedFrom(linkageBundle)
208             .addSupport(new YinElementStatementSupport(config))
209             .addSupport(new ArgumentStatementSupport(config))
210             .addSupport(new ExtensionStatementSupport(config))
211             .addSupport(SchemaTreeNamespace.getInstance())
212             .addSupport(ExtensionNamespace.BEHAVIOUR)
213             .addSupport(new TypedefStatementSupport(config))
214             .addSupport(TypeNamespace.BEHAVIOUR)
215             .addVersionSpecificSupport(VERSION_1, IdentityStatementSupport.rfc6020Instance(config))
216             .addVersionSpecificSupport(VERSION_1_1, IdentityStatementSupport.rfc7950Instance(config))
217             .addSupport(IdentityNamespace.BEHAVIOUR)
218             .addSupport(new DefaultStatementSupport(config))
219             .addSupport(new StatusStatementSupport(config))
220             .addSupport(BaseTypeNamespace.BEHAVIOUR)
221             .addVersionSpecificSupport(VERSION_1, new TypeStatementRFC6020Support(config))
222             .addVersionSpecificSupport(VERSION_1_1, new TypeStatementRFC7950Support(config))
223             .addSupport(new UnitsStatementSupport(config))
224             .addSupport(new RequireInstanceStatementSupport(config))
225             .addVersionSpecificSupport(VERSION_1, BitStatementSupport.rfc6020Instance(config))
226             .addVersionSpecificSupport(VERSION_1_1, BitStatementSupport.rfc7950Instance(config))
227             .addSupport(PathStatementSupport.strictInstance(config))
228             .addVersionSpecificSupport(VERSION_1, EnumStatementSupport.rfc6020Instance(config))
229             .addVersionSpecificSupport(VERSION_1_1, EnumStatementSupport.rfc7950Instance(config))
230             .addSupport(new LengthStatementSupport(config))
231             .addVersionSpecificSupport(VERSION_1, PatternStatementSupport.rfc6020Instance(config))
232             .addVersionSpecificSupport(VERSION_1_1, PatternStatementSupport.rfc7950Instance(config))
233             .addVersionSpecificSupport(VERSION_1_1, new ModifierStatementSupport(config))
234             .addSupport(new RangeStatementSupport(config))
235             .addSupport(new KeyStatementSupport(config))
236             .addVersionSpecificSupport(VERSION_1, ContainerStatementSupport.rfc6020Instance(config))
237             .addVersionSpecificSupport(VERSION_1_1, ContainerStatementSupport.rfc7950Instance(config))
238             .addVersionSpecificSupport(VERSION_1, GroupingStatementSupport.rfc6020Instance(config))
239             .addVersionSpecificSupport(VERSION_1_1, GroupingStatementSupport.rfc7950Instance(config))
240             .addVersionSpecificSupport(VERSION_1, ListStatementSupport.rfc6020Instance(config))
241             .addVersionSpecificSupport(VERSION_1_1, ListStatementSupport.rfc7950Instance(config))
242             .addSupport(ConfigListWarningNamespace.BEHAVIOUR)
243             .addSupport(new UniqueStatementSupport(config))
244             .addVersionSpecificSupport(VERSION_1_1, new ActionStatementSupport(config))
245             .addVersionSpecificSupport(VERSION_1, new RpcStatementSupport(config))
246             .addVersionSpecificSupport(VERSION_1_1, new RpcStatementSupport(config))
247             .addVersionSpecificSupport(VERSION_1, InputStatementSupport.rfc6020Instance(config))
248             .addVersionSpecificSupport(VERSION_1_1, InputStatementSupport.rfc7950Instance(config))
249             .addVersionSpecificSupport(VERSION_1, OutputStatementSupport.rfc6020Instance(config))
250             .addVersionSpecificSupport(VERSION_1_1, OutputStatementSupport.rfc7950Instance(config))
251             .addVersionSpecificSupport(VERSION_1, new NotificationStatementRFC6020Support(config))
252             .addVersionSpecificSupport(VERSION_1_1, new NotificationStatementRFC7950Support(config))
253             .addSupport(new FractionDigitsStatementSupport(config))
254             .addSupport(new BaseStatementSupport(config))
255             .addSupport(StatementDefinitionNamespace.BEHAVIOUR)
256             .build();
257     }
258
259     /**
260      * Returns a pre-built {@link CrossSourceStatementReactor} supporting RFC6020 and RFC7950, along with OpenConfig
261      * semantic version extension. This is useful for parsing near-vanilla YANG models while providing complete
262      * support for semantic versions.
263      *
264      * @return A shared reactor instance.
265      */
266     public static @NonNull CrossSourceStatementReactor defaultReactor() {
267         return ServiceLoaderState.DefaultReactor.INSTANCE;
268     }
269
270     /**
271      * Returns a partially-configured {@link CustomCrossSourceStatementReactorBuilder}, with RFC6020/RFC7950
272      * and OpenConfig semantic version support enabled.
273      *
274      * @return A new {@link CustomCrossSourceStatementReactorBuilder}.
275      */
276     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder() {
277         return defaultReactorBuilder(YangParserConfiguration.DEFAULT);
278     }
279
280     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
281             final YangParserConfiguration config) {
282         return vanillaReactorBuilder(config);
283     }
284
285     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
286             final YangXPathParserFactory xpathFactory) {
287         return defaultReactorBuilder(xpathFactory, YangParserConfiguration.DEFAULT);
288     }
289
290     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
291             final YangXPathParserFactory xpathFactory, final YangParserConfiguration config) {
292         return vanillaReactorBuilder(xpathFactory, config);
293     }
294
295     /**
296      * Returns a pre-built {@link CrossSourceStatementReactor} supporting both RFC6020 and RFC7950. This is useful
297      * for parsing vanilla YANG models without any semantic support for extensions. Notably missing is the semantic
298      * version extension, hence attempts to use semantic version mode will cause failures.
299      *
300      * @return A shared reactor instance.
301      */
302     public static @NonNull CrossSourceStatementReactor vanillaReactor() {
303         return ServiceLoaderState.VanillaReactor.INSTANCE;
304     }
305
306     /**
307      * Returns a partially-configured {@link CustomCrossSourceStatementReactorBuilder}, with vanilla RFC6020/RFC7950
308      * support enabled.
309      *
310      * @return A new {@link CustomCrossSourceStatementReactorBuilder}.
311      */
312     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder() {
313         return vanillaReactorBuilder(YangParserConfiguration.DEFAULT);
314     }
315
316     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
317             final YangParserConfiguration config) {
318         return vanillaReactorBuilder(ServiceLoaderState.XPath.INSTANCE, config);
319     }
320
321     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
322             final @NonNull YangXPathParserFactory xpathFactory) {
323         return vanillaReactorBuilder(xpathFactory, YangParserConfiguration.DEFAULT);
324     }
325
326     public static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
327             final @NonNull YangXPathParserFactory xpathFactory, final YangParserConfiguration config) {
328         return vanillaReactorBuilder(new XPathSupport(xpathFactory), config);
329     }
330
331     private static @NonNull CustomCrossSourceStatementReactorBuilder vanillaReactorBuilder(
332             final @NonNull XPathSupport xpathSupport, final YangParserConfiguration config) {
333         final StatementSupportBundle preLinkageBundle = preLinkageBundle(config);
334         final StatementSupportBundle linkageBundle = linkageBundle(preLinkageBundle, config);
335         final StatementSupportBundle stmtDefBundle = stmtDefBundle(linkageBundle, config);
336         final StatementSupportBundle fullDeclarationBundle =
337             fullDeclarationBundle(stmtDefBundle, xpathSupport, config);
338
339         return new CustomCrossSourceStatementReactorBuilder(SUPPORTED_VERSIONS)
340                 .addAllSupports(ModelProcessingPhase.INIT, INIT_BUNDLE)
341                 .addAllSupports(ModelProcessingPhase.SOURCE_PRE_LINKAGE, preLinkageBundle)
342                 .addAllSupports(ModelProcessingPhase.SOURCE_LINKAGE, linkageBundle)
343                 .addAllSupports(ModelProcessingPhase.STATEMENT_DEFINITION, stmtDefBundle)
344                 .addAllSupports(ModelProcessingPhase.FULL_DECLARATION, fullDeclarationBundle)
345                 .addAllSupports(ModelProcessingPhase.EFFECTIVE_MODEL, fullDeclarationBundle)
346                 .addValidationBundle(ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS,
347                     YangValidationBundles.SUPPORTED_REFINE_SUBSTATEMENTS)
348                 .addValidationBundle(ValidationBundleType.SUPPORTED_AUGMENT_TARGETS,
349                     YangValidationBundles.SUPPORTED_AUGMENT_TARGETS)
350
351                 // FIXME: 7.0.0: we do not seem to need this validation bundle
352                 .addValidationBundle(ValidationBundleType.SUPPORTED_CASE_SHORTHANDS,
353                     YangValidationBundles.SUPPORTED_CASE_SHORTHANDS)
354
355                 .addValidationBundle(ValidationBundleType.SUPPORTED_DATA_NODES,
356                     YangValidationBundles.SUPPORTED_DATA_NODES);
357     }
358
359     private static @NonNull StatementSupportBundle fullDeclarationBundle(final StatementSupportBundle stmtDefBundle,
360             final XPathSupport xpathSupport, final YangParserConfiguration config) {
361         return StatementSupportBundle.derivedFrom(stmtDefBundle)
362             .addSupport(new LeafStatementSupport(config))
363             .addSupport(new ConfigStatementSupport(config))
364             .addSupport(new DeviationStatementSupport(config))
365             .addVersionSpecificSupport(VERSION_1, new DeviateStatementRFC6020Support(config))
366             .addVersionSpecificSupport(VERSION_1_1, new DeviateStatementRFC7950Support(config))
367             .addVersionSpecificSupport(VERSION_1, ChoiceStatementSupport.rfc6020Instance(config))
368             .addVersionSpecificSupport(VERSION_1_1, ChoiceStatementSupport.rfc7950Instance(config))
369             .addVersionSpecificSupport(VERSION_1, CaseStatementSupport.rfc6020Instance(config))
370             .addVersionSpecificSupport(VERSION_1_1, CaseStatementSupport.rfc7950Instance(config))
371             .addSupport(new MustStatementSupport(xpathSupport, config))
372             .addSupport(new MandatoryStatementSupport(config))
373             .addSupport(new AnyxmlStatementSupport(config))
374             .addVersionSpecificSupport(VERSION_1_1, new AnydataStatementSupport(config))
375             .addSupport(FeatureNamespace.BEHAVIOUR)
376             .addVersionSpecificSupport(VERSION_1, new IfFeatureStatementRFC6020Support(config))
377             .addVersionSpecificSupport(VERSION_1_1, new IfFeatureStatementRFC7950Support(config))
378             .addSupport(GroupingNamespace.BEHAVIOUR)
379             .addSupport(SourceGroupingNamespace.BEHAVIOUR)
380             .addSupport(new UsesStatementSupport(config))
381             .addSupport(new ErrorMessageStatementSupport(config))
382             .addSupport(new ErrorAppTagStatementSupport(config))
383             .addVersionSpecificSupport(VERSION_1, LeafListStatementSupport.rfc6020Instance(config))
384             .addVersionSpecificSupport(VERSION_1_1, LeafListStatementSupport.rfc7950Instance(config))
385             .addSupport(new PresenceStatementSupport(config))
386             .addSupport(new MaxElementsStatementSupport(config))
387             .addSupport(new MinElementsStatementSupport(config))
388             .addSupport(new OrderedByStatementSupport(config))
389             .addSupport(new WhenStatementSupport(xpathSupport, config))
390             .addSupport(AugmentImplicitHandlingNamespace.BEHAVIOUR)
391             .addVersionSpecificSupport(VERSION_1, new AugmentStatementRFC6020Support(config))
392             .addVersionSpecificSupport(VERSION_1_1, new AugmentStatementRFC7950Support(config))
393             .addSupport(RefineTargetNamespace.BEHAVIOUR)
394             .addVersionSpecificSupport(VERSION_1, RefineStatementSupport.rfc6020Instance(config))
395             .addVersionSpecificSupport(VERSION_1_1, RefineStatementSupport.rfc7950Instance(config))
396             .addSupport(new FeatureStatementSupport(config))
397             .addSupport(new PositionStatementSupport(config))
398             .addSupport(new ValueStatementSupport(config))
399             .addSupport(YangNamespaceContextNamespace.BEHAVIOUR)
400             .build();
401     }
402 }