Scripted update of if statements
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / YangInferencePipeline.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
9
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;
13
14 import com.google.common.collect.ImmutableMap;
15 import java.util.Map;
16 import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
17 import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
18 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
19 import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
20 import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
21 import org.opendaylight.yangtools.yang.parser.spi.PreLinkageModuleNamespace;
22 import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
23 import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedIdentitiesNamespace;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
27 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
28 import org.opendaylight.yangtools.yang.parser.spi.source.AnyxmlSchemaLocationNamespace;
29 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
30 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleIdentifier;
31 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
32 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
33 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
34 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToIdentifier;
35 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
36 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
37 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
38 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToNamespace;
39 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
40 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
41 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
42 import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
43 import org.opendaylight.yangtools.yang.parser.spi.source.StmtOrderingNamespace;
44 import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
45 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
46 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
47 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
48
49 public final class YangInferencePipeline {
50
51     public static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle
52             .builder().addSupport(global(ValidationBundlesNamespace.class))
53             .addSupport(global(SupportedFeaturesNamespace.class))
54             .build();
55
56     public static final StatementSupportBundle PRE_LINKAGE_BUNDLE = StatementSupportBundle
57             .derivedFrom(INIT_BUNDLE)
58             .addSupport(new ModuleStatementSupport())
59             .addSupport(new SubmoduleStatementImpl.Definition())
60             .addSupport(new NamespaceStatementImpl.Definition())
61             .addSupport(new ImportStatementDefinition())
62             .addSupport(new IncludeStatementImpl.Definition())
63             .addSupport(new PrefixStatementImpl.Definition())
64             .addSupport(new YangVersionStatementImpl.Definition())
65             .addSupport(global(ModuleNameToNamespace.class))
66             .addSupport(global(PreLinkageModuleNamespace.class))
67             .addSupport(sourceLocal(ImpPrefixToNamespace.class))
68             .build();
69
70     public static final StatementSupportBundle LINKAGE_BUNDLE = StatementSupportBundle
71             .derivedFrom(PRE_LINKAGE_BUNDLE)
72             .addSupport(new DescriptionStatementImpl.Definition())
73             .addSupport(new RevisionStatementImpl.Definition())
74             .addSupport(new RevisionDateStatementImpl.Definition())
75             .addSupport(new ReferenceStatementImpl.Definition())
76             .addSupport(new ContactStatementImpl.Definition())
77             .addSupport(new OrganizationStatementImpl.Definition())
78             .addSupport(new BelongsToStatementImpl.Definition())
79             .addSupport(global(ModuleNamespace.class))
80             .addSupport(global(ModuleNamespaceForBelongsTo.class))
81             .addSupport(global(SubmoduleNamespace.class))
82             .addSupport(global(NamespaceToModule.class))
83             .addSupport(global(ModuleNameToModuleQName.class))
84             .addSupport(global(ModuleCtxToModuleQName.class))
85             .addSupport(global(ModuleQNameToModuleName.class))
86             .addSupport(global(PrefixToModule.class))
87             .addSupport(global(ModuleIdentifierToModuleQName.class))
88             .addSupport(QNameCacheNamespace.getInstance())
89             .addSupport(sourceLocal(ImportedModuleContext.class))
90             .addSupport(sourceLocal(IncludedModuleContext.class))
91             .addSupport(sourceLocal(IncludedSubmoduleNameToIdentifier.class))
92             .addSupport(sourceLocal(ImpPrefixToModuleIdentifier.class))
93             .addSupport(sourceLocal(BelongsToPrefixToModuleIdentifier.class))
94             .addSupport(sourceLocal(URIStringToImpPrefix.class))
95             .addSupport(sourceLocal(BelongsToModuleContext.class))
96             .addSupport(sourceLocal(QNameToStatementDefinition.class))
97             .addSupport(sourceLocal(BelongsToPrefixToModuleName.class))
98             .build();
99
100     private static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle
101             .derivedFrom(LINKAGE_BUNDLE)
102             .addSupport(new YinElementStatementImpl.Definition())
103             .addSupport(new ArgumentStatementImpl.Definition())
104             .addSupport(new ExtensionStatementImpl.Definition())
105             .addSupport(new ChildSchemaNodes<>())
106             .addSupport(new SchemaNodeIdentifierBuildNamespace())
107             .addSupport(global(ExtensionNamespace.class))
108             .addSupport(new TypedefStatementImpl.Definition())
109             .addSupport(treeScoped(TypeNamespace.class))
110             .addSupport(new IdentityStatementImpl.Definition())
111             .addSupport(global(IdentityNamespace.class))
112             .addSupport(new DefaultStatementImpl.Definition())
113             .addSupport(new StatusStatementImpl.Definition())
114             .addSupport(new TypeStatementImpl.Definition())
115             .addSupport(new UnitsStatementImpl.Definition())
116             .addSupport(new RequireInstanceStatementImpl.Definition())
117             .addSupport(new BitStatementImpl.Definition())
118             .addSupport(new PathStatementImpl.Definition())
119             .addSupport(new EnumStatementImpl.Definition())
120             .addSupport(new LengthStatementImpl.Definition())
121             .addSupport(new PatternStatementImpl.Definition())
122             .addSupport(new RangeStatementImpl.Definition())
123             .addSupport(new ContainerStatementImpl.Definition())
124             .addSupport(new GroupingStatementImpl.Definition())
125             .addSupport(new ListStatementImpl.Definition())
126             .addSupport(new UniqueStatementImpl.Definition())
127             .addSupport(new RpcStatementImpl.Definition())
128             .addSupport(new InputStatementImpl.Definition())
129             .addSupport(new OutputStatementImpl.Definition())
130             .addSupport(new NotificationStatementImpl.Definition())
131             .addSupport(new FractionDigitsStatementImpl.Definition())
132             .addSupport(new BaseStatementImpl.Definition())
133             .addSupport(global(DerivedIdentitiesNamespace.class))
134             .build();
135
136     private static final StatementSupportBundle FULL_DECL_BUNDLE = StatementSupportBundle
137             .derivedFrom(STMT_DEF_BUNDLE)
138             .addSupport(new LeafStatementImpl.Definition())
139             .addSupport(new ConfigStatementImpl.Definition())
140             .addSupport(new DeviationStatementImpl.Definition())
141             .addSupport(new DeviateStatementImpl.Definition())
142             .addSupport(new ChoiceStatementImpl.Definition())
143             .addSupport(new CaseStatementImpl.Definition())
144             .addSupport(new MustStatementImpl.Definition())
145             .addSupport(new MandatoryStatementImpl.Definition())
146             .addSupport(new AnyxmlStatementImpl.Definition())
147             .addSupport(new IfFeatureStatementImpl.Definition())
148             .addSupport(new UsesStatementImpl.Definition())
149             .addSupport(treeScoped(GroupingNamespace.class)) //treeScoped
150             .addSupport(new ErrorMessageStatementImpl.Definition())
151             .addSupport(new ErrorAppTagStatementImpl.Definition())
152             .addSupport(new LeafListStatementImpl.Definition())
153             .addSupport(new PresenceStatementImpl.Definition())
154             .addSupport(new KeyStatementImpl.Definition())
155             .addSupport(new MaxElementsStatementImpl.Definition())
156             .addSupport(new MinElementsStatementImpl.Definition())
157             .addSupport(new OrderedByStatementImpl.Definition())
158             .addSupport(new WhenStatementImpl.Definition())
159             .addSupport(new AugmentStatementImpl.Definition())
160             .addSupport(new RefineStatementImpl.Definition())
161             .addSupport(new FeatureStatementImpl.Definition())
162             .addSupport(new PositionStatementImpl.Definition())
163             .addSupport(new ValueStatementImpl.Definition())
164             .addSupport(new AnyxmlSchemaLocationStatementImpl.AnyxmlSchemaLocationSupport())
165             .addSupport(treeScoped(AnyxmlSchemaLocationNamespace.class))
166             .addSupport(global(StmtOrderingNamespace.class))
167             .build();
168
169     public static final Map<ModelProcessingPhase, StatementSupportBundle> RFC6020_BUNDLES = ImmutableMap
170             .<ModelProcessingPhase, StatementSupportBundle> builder()
171             .put(ModelProcessingPhase.SOURCE_PRE_LINKAGE, PRE_LINKAGE_BUNDLE)
172             .put(ModelProcessingPhase.SOURCE_LINKAGE, LINKAGE_BUNDLE)
173             .put(ModelProcessingPhase.STATEMENT_DEFINITION, STMT_DEF_BUNDLE)
174             .put(ModelProcessingPhase.FULL_DECLARATION, FULL_DECL_BUNDLE)
175             .put(ModelProcessingPhase.EFFECTIVE_MODEL, FULL_DECL_BUNDLE)
176             .build();
177
178     public static final CrossSourceStatementReactor RFC6020_REACTOR = CrossSourceStatementReactor
179             .builder()
180             .setBundle(ModelProcessingPhase.INIT, INIT_BUNDLE)
181             .setBundle(ModelProcessingPhase.SOURCE_PRE_LINKAGE, PRE_LINKAGE_BUNDLE)
182             .setBundle(ModelProcessingPhase.SOURCE_LINKAGE, LINKAGE_BUNDLE)
183             .setBundle(ModelProcessingPhase.STATEMENT_DEFINITION,
184                     STMT_DEF_BUNDLE)
185             .setBundle(ModelProcessingPhase.FULL_DECLARATION, FULL_DECL_BUNDLE)
186             .setBundle(ModelProcessingPhase.EFFECTIVE_MODEL, FULL_DECL_BUNDLE)
187             .setValidationBundle(
188                     ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS,
189                     YangValidationBundles.SUPPORTED_REFINE_SUBSTATEMENTS)
190             .setValidationBundle(ValidationBundleType.SUPPORTED_AUGMENT_TARGETS,
191                     YangValidationBundles.SUPPORTED_AUGMENT_TARGETS)
192             .setValidationBundle(ValidationBundleType.SUPPORTED_CASE_SHORTHANDS,
193                     YangValidationBundles.SUPPORTED_CASE_SHORTHANDS)
194             .setValidationBundle(ValidationBundleType.SUPPORTED_DATA_NODES,
195                     YangValidationBundles.SUPPORTED_DATA_NODES)
196              .build();
197
198     private YangInferencePipeline() {
199         throw new UnsupportedOperationException("Utility class");
200     }
201 }