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