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.stmt.rfc6020;
10 import static org.opendaylight.yangtools.yang.common.YangVersion.VERSION_1;
11 import static org.opendaylight.yangtools.yang.common.YangVersion.VERSION_1_1;
12 import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.global;
13 import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.sourceLocal;
14 import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.treeScoped;
16 import com.google.common.collect.ImmutableMap;
17 import com.google.common.collect.Sets;
18 import java.util.Collection;
21 import org.opendaylight.yangtools.yang.common.YangVersion;
22 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
23 import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
24 import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
25 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
26 import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
27 import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
28 import org.opendaylight.yangtools.yang.parser.spi.PreLinkageModuleNamespace;
29 import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
30 import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
31 import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedIdentitiesNamespace;
32 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
33 import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
34 import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionModuleNamespace;
35 import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
36 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementDefinitionNamespace;
37 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
38 import org.opendaylight.yangtools.yang.parser.spi.source.AnyxmlSchemaLocationNamespace;
39 import org.opendaylight.yangtools.yang.parser.spi.source.AugmentToChoiceNamespace;
40 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
41 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleIdentifier;
42 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
43 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
44 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
45 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToSemVerModuleIdentifier;
46 import org.opendaylight.yangtools.yang.parser.spi.source.ImportedModuleContext;
47 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedModuleContext;
48 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToIdentifier;
49 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleIdentifier;
50 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
51 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
52 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
53 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToNamespace;
54 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
55 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
56 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
57 import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
58 import org.opendaylight.yangtools.yang.parser.spi.source.StmtOrderingNamespace;
59 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
60 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
61 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
62 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
63 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ActionStatementImpl;
64 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.AnydataStatementImpl;
65 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.AugmentStatementRfc7950Support;
66 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.CaseStatementRfc7950Support;
67 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ChoiceStatementRfc7950Support;
68 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ContainerStatementRfc7950Support;
69 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.GroupingStatementRfc7950Support;
70 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ImportStatementRfc7950Support;
71 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.IncludeStatementRfc7950Support;
72 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.InputStatementRfc7950Support;
73 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ListStatementRfc7950Support;
74 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ModuleStatementRfc7950Support;
75 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.NotificationStatementRfc7950Support;
76 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.OutputStatementRfc7950Support;
77 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.SubmoduleStatementRfc7950Support;
79 public final class YangInferencePipeline {
80 public static final Set<YangVersion> SUPPORTED_VERSIONS = Sets.immutableEnumSet(VERSION_1, VERSION_1_1);
82 public static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle
83 .builder(SUPPORTED_VERSIONS).addSupport(global(ValidationBundlesNamespace.class))
84 .addSupport(global(SupportedFeaturesNamespace.class))
87 public static final StatementSupportBundle PRE_LINKAGE_BUNDLE = StatementSupportBundle
88 .derivedFrom(INIT_BUNDLE)
89 .addVersionSpecificSupport(VERSION_1, new ModuleStatementSupport())
90 .addVersionSpecificSupport(VERSION_1_1, new ModuleStatementRfc7950Support())
91 .addVersionSpecificSupport(VERSION_1, new SubmoduleStatementImpl.Definition())
92 .addVersionSpecificSupport(VERSION_1_1, new SubmoduleStatementRfc7950Support())
93 .addSupport(new NamespaceStatementImpl.Definition())
94 .addVersionSpecificSupport(VERSION_1, new ImportStatementDefinition())
95 .addVersionSpecificSupport(VERSION_1_1, new ImportStatementRfc7950Support())
96 .addVersionSpecificSupport(VERSION_1, new IncludeStatementImpl.Definition())
97 .addVersionSpecificSupport(VERSION_1_1, new IncludeStatementRfc7950Support())
98 .addSupport(new PrefixStatementImpl.Definition())
99 .addSupport(new YangVersionStatementImpl.Definition())
100 .addSupport(new RevisionStatementImpl.Definition())
101 .addSupport(global(ModuleNameToNamespace.class))
102 .addSupport(global(PreLinkageModuleNamespace.class))
103 .addSupport(sourceLocal(ImpPrefixToNamespace.class))
104 .addSupport(global(ModuleCtxToModuleQName.class))
107 public static final StatementSupportBundle LINKAGE_BUNDLE = StatementSupportBundle
108 .derivedFrom(PRE_LINKAGE_BUNDLE)
109 .addSupport(new DescriptionStatementImpl.Definition())
110 .addSupport(new RevisionDateStatementImpl.Definition())
111 .addSupport(new ReferenceStatementImpl.Definition())
112 .addSupport(new ContactStatementImpl.Definition())
113 .addSupport(new OrganizationStatementImpl.Definition())
114 .addSupport(new BelongsToStatementImpl.Definition())
115 .addSupport(global(ModuleNamespace.class))
116 .addSupport(global(ModuleNamespaceForBelongsTo.class))
117 .addSupport(global(SubmoduleNamespace.class))
118 .addSupport(global(NamespaceToModule.class))
119 .addSupport(global(ModuleNameToModuleQName.class))
120 .addSupport(global(ModuleCtxToModuleIdentifier.class))
121 .addSupport(global(ModuleQNameToModuleName.class))
122 .addSupport(global(PrefixToModule.class))
123 .addSupport(global(ModuleIdentifierToModuleQName.class))
124 .addSupport(QNameCacheNamespace.getInstance())
125 .addSupport(sourceLocal(ImportedModuleContext.class))
126 .addSupport(sourceLocal(IncludedModuleContext.class))
127 .addSupport(sourceLocal(IncludedSubmoduleNameToIdentifier.class))
128 .addSupport(sourceLocal(ImpPrefixToModuleIdentifier.class))
129 .addSupport(sourceLocal(BelongsToPrefixToModuleIdentifier.class))
130 .addSupport(sourceLocal(URIStringToImpPrefix.class))
131 .addSupport(sourceLocal(BelongsToModuleContext.class))
132 .addSupport(sourceLocal(QNameToStatementDefinition.class))
133 .addSupport(sourceLocal(BelongsToPrefixToModuleName.class))
134 .addSupport(new SemanticVersionStatementImpl.SemanticVersionSupport())
135 .addSupport(global(SemanticVersionNamespace.class))
136 .addSupport(global(SemanticVersionModuleNamespace.class))
137 .addSupport(sourceLocal(ImpPrefixToSemVerModuleIdentifier.class))
140 public static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle
141 .derivedFrom(LINKAGE_BUNDLE)
142 .addSupport(new YinElementStatementImpl.Definition())
143 .addSupport(new ArgumentStatementImpl.Definition())
144 .addSupport(new ExtensionStatementImpl.Definition())
145 .addSupport(new ChildSchemaNodes<>())
146 .addSupport(new SchemaNodeIdentifierBuildNamespace())
147 .addSupport(global(ExtensionNamespace.class))
148 .addSupport(new TypedefStatementImpl.Definition())
149 .addSupport(treeScoped(TypeNamespace.class))
150 .addSupport(new IdentityStatementImpl.Definition())
151 .addSupport(global(IdentityNamespace.class))
152 .addSupport(new DefaultStatementImpl.Definition())
153 .addSupport(new StatusStatementImpl.Definition())
154 .addSupport(new TypeStatementImpl.Definition())
155 .addSupport(new UnitsStatementImpl.Definition())
156 .addSupport(new RequireInstanceStatementImpl.Definition())
157 .addSupport(new BitStatementImpl.Definition())
158 .addSupport(new PathStatementImpl.Definition())
159 .addSupport(new EnumStatementImpl.Definition())
160 .addSupport(new LengthStatementImpl.Definition())
161 .addSupport(new PatternStatementImpl.Definition())
162 .addSupport(new RangeStatementImpl.Definition())
163 .addVersionSpecificSupport(VERSION_1, new ContainerStatementImpl.Definition())
164 .addVersionSpecificSupport(VERSION_1_1, new ContainerStatementRfc7950Support())
165 .addVersionSpecificSupport(VERSION_1, new GroupingStatementImpl.Definition())
166 .addVersionSpecificSupport(VERSION_1_1, new GroupingStatementRfc7950Support())
167 .addVersionSpecificSupport(VERSION_1, new ListStatementImpl.Definition())
168 .addVersionSpecificSupport(VERSION_1_1, new ListStatementRfc7950Support())
169 .addSupport(new UniqueStatementImpl.Definition())
170 .addVersionSpecificSupport(VERSION_1_1, new ActionStatementImpl.Definition())
171 .addSupport(new RpcStatementImpl.Definition())
172 .addVersionSpecificSupport(VERSION_1, new InputStatementImpl.Definition())
173 .addVersionSpecificSupport(VERSION_1_1, new InputStatementRfc7950Support())
174 .addVersionSpecificSupport(VERSION_1, new OutputStatementImpl.Definition())
175 .addVersionSpecificSupport(VERSION_1_1, new OutputStatementRfc7950Support())
176 .addVersionSpecificSupport(VERSION_1, new NotificationStatementImpl.Definition())
177 .addVersionSpecificSupport(VERSION_1_1, new NotificationStatementRfc7950Support())
178 .addSupport(new FractionDigitsStatementImpl.Definition())
179 .addSupport(new BaseStatementImpl.Definition())
180 .addSupport(global(DerivedIdentitiesNamespace.class))
181 .addSupport(global(StatementDefinitionNamespace.class))
184 public static final StatementSupportBundle FULL_DECL_BUNDLE = StatementSupportBundle
185 .derivedFrom(STMT_DEF_BUNDLE)
186 .addSupport(new LeafStatementImpl.Definition())
187 .addSupport(new ConfigStatementImpl.Definition())
188 .addSupport(new DeviationStatementImpl.Definition())
189 .addSupport(new DeviateStatementImpl.Definition())
190 .addVersionSpecificSupport(VERSION_1, new ChoiceStatementImpl.Definition())
191 .addVersionSpecificSupport(VERSION_1_1, new ChoiceStatementRfc7950Support())
192 .addVersionSpecificSupport(VERSION_1, new CaseStatementImpl.Definition())
193 .addVersionSpecificSupport(VERSION_1_1, new CaseStatementRfc7950Support())
194 .addSupport(new MustStatementImpl.Definition())
195 .addSupport(new MandatoryStatementImpl.Definition())
196 .addSupport(new AnyxmlStatementImpl.Definition())
197 .addVersionSpecificSupport(VERSION_1_1, new AnydataStatementImpl.Definition())
198 .addSupport(new IfFeatureStatementImpl.Definition())
199 .addSupport(new UsesStatementImpl.Definition())
200 .addSupport(treeScoped(GroupingNamespace.class)) //treeScoped
201 .addSupport(new ErrorMessageStatementImpl.Definition())
202 .addSupport(new ErrorAppTagStatementImpl.Definition())
203 .addSupport(new LeafListStatementImpl.Definition())
204 .addSupport(new PresenceStatementImpl.Definition())
205 .addSupport(new KeyStatementImpl.Definition())
206 .addSupport(new MaxElementsStatementImpl.Definition())
207 .addSupport(new MinElementsStatementImpl.Definition())
208 .addSupport(new OrderedByStatementImpl.Definition())
209 .addSupport(new WhenStatementImpl.Definition())
210 .addVersionSpecificSupport(VERSION_1, new AugmentStatementImpl.Definition())
211 .addVersionSpecificSupport(VERSION_1_1, new AugmentStatementRfc7950Support())
212 .addSupport(treeScoped(AugmentToChoiceNamespace.class))
213 .addSupport(new RefineStatementImpl.Definition())
214 .addSupport(new FeatureStatementImpl.Definition())
215 .addSupport(new PositionStatementImpl.Definition())
216 .addSupport(new ValueStatementImpl.Definition())
217 .addSupport(new AnyxmlSchemaLocationStatementImpl.AnyxmlSchemaLocationSupport())
218 .addSupport(treeScoped(AnyxmlSchemaLocationNamespace.class))
219 .addSupport(global(StmtOrderingNamespace.class))
222 public static final Map<ModelProcessingPhase, StatementSupportBundle> RFC6020_BUNDLES = ImmutableMap
223 .<ModelProcessingPhase, StatementSupportBundle> builder()
224 .put(ModelProcessingPhase.INIT, INIT_BUNDLE)
225 .put(ModelProcessingPhase.SOURCE_PRE_LINKAGE, PRE_LINKAGE_BUNDLE)
226 .put(ModelProcessingPhase.SOURCE_LINKAGE, LINKAGE_BUNDLE)
227 .put(ModelProcessingPhase.STATEMENT_DEFINITION, STMT_DEF_BUNDLE)
228 .put(ModelProcessingPhase.FULL_DECLARATION, FULL_DECL_BUNDLE)
229 .put(ModelProcessingPhase.EFFECTIVE_MODEL, FULL_DECL_BUNDLE)
232 public static final Map<ValidationBundleType, Collection<StatementDefinition>> RFC6020_VALIDATION_BUNDLE = ImmutableMap
233 .<ValidationBundleType, Collection<StatementDefinition>> builder()
234 .put(ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS, YangValidationBundles.SUPPORTED_REFINE_SUBSTATEMENTS)
235 .put(ValidationBundleType.SUPPORTED_AUGMENT_TARGETS, YangValidationBundles.SUPPORTED_AUGMENT_TARGETS)
236 .put(ValidationBundleType.SUPPORTED_CASE_SHORTHANDS, YangValidationBundles.SUPPORTED_CASE_SHORTHANDS)
237 .put(ValidationBundleType.SUPPORTED_DATA_NODES, YangValidationBundles.SUPPORTED_DATA_NODES)
240 public static final CrossSourceStatementReactor RFC6020_REACTOR = CrossSourceStatementReactor
242 .setBundle(ModelProcessingPhase.INIT, INIT_BUNDLE)
243 .setBundle(ModelProcessingPhase.SOURCE_PRE_LINKAGE, PRE_LINKAGE_BUNDLE)
244 .setBundle(ModelProcessingPhase.SOURCE_LINKAGE, LINKAGE_BUNDLE)
245 .setBundle(ModelProcessingPhase.STATEMENT_DEFINITION,
247 .setBundle(ModelProcessingPhase.FULL_DECLARATION, FULL_DECL_BUNDLE)
248 .setBundle(ModelProcessingPhase.EFFECTIVE_MODEL, FULL_DECL_BUNDLE)
249 .setValidationBundle(
250 ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS,
251 YangValidationBundles.SUPPORTED_REFINE_SUBSTATEMENTS)
252 .setValidationBundle(ValidationBundleType.SUPPORTED_AUGMENT_TARGETS,
253 YangValidationBundles.SUPPORTED_AUGMENT_TARGETS)
254 .setValidationBundle(ValidationBundleType.SUPPORTED_CASE_SHORTHANDS,
255 YangValidationBundles.SUPPORTED_CASE_SHORTHANDS)
256 .setValidationBundle(ValidationBundleType.SUPPORTED_DATA_NODES,
257 YangValidationBundles.SUPPORTED_DATA_NODES)
260 private YangInferencePipeline() {
261 throw new UnsupportedOperationException("Utility class");