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