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