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