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