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;
13 import static org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
15 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
17 import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
18 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedIdentitiesNamespace;
20 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
21 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToIdentifier;
22 import org.opendaylight.yangtools.yang.parser.spi.ExtensionNamespace;
23 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
24 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
25 import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
26 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
27 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
28 import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
29 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
30 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
31 import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
32 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
33 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
34 import com.google.common.collect.ImmutableMap;
36 import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
37 import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
38 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
39 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
40 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
42 public final class YangInferencePipeline {
44 public static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle
45 .builder().addSupport(global(ValidationBundlesNamespace.class))
48 public static final StatementSupportBundle LINKAGE_BUNDLE = StatementSupportBundle
49 .derivedFrom(INIT_BUNDLE)
50 .addSupport(new ModuleStatementSupport())
51 .addSupport(new SubmoduleStatementImpl.Definition())
52 .addSupport(new NamespaceStatementImpl.Definition())
53 .addSupport(new ImportStatementDefinition())
54 .addSupport(new IncludeStatementImpl.Definition())
55 .addSupport(new PrefixStatementImpl.Definition())
56 .addSupport(new YangVersionStatementImpl.Definition())
57 .addSupport(new DescriptionStatementImpl.Definition())
58 .addSupport(new RevisionStatementImpl.Definition())
59 .addSupport(new RevisionDateStatementImpl.Definition())
60 .addSupport(new ReferenceStatementImpl.Definition())
61 .addSupport(new ContactStatementImpl.Definition())
62 .addSupport(new OrganizationStatementImpl.Definition())
63 .addSupport(new BelongsToStatementImpl.Definition())
64 .addSupport(global(ModuleNamespace.class))
65 .addSupport(global(ModuleNamespaceForBelongsTo.class))
66 .addSupport(global(SubmoduleNamespace.class))
67 .addSupport(global(NamespaceToModule.class))
68 .addSupport(global(ModuleNameToModuleQName.class))
69 .addSupport(global(ModuleCtxToModuleQName.class))
70 .addSupport(global(ModuleQNameToModuleName.class))
71 .addSupport(global(PrefixToModule.class))
72 .addSupport(global(ModuleIdentifierToModuleQName.class))
73 .addSupport(sourceLocal(ImportedModuleContext.class))
74 .addSupport(sourceLocal(IncludedModuleContext.class))
75 .addSupport(sourceLocal(IncludedSubmoduleNameToIdentifier.class))
76 .addSupport(sourceLocal(ImpPrefixToModuleIdentifier.class))
77 .addSupport(sourceLocal(BelongsToModuleContext.class))
78 .addSupport(sourceLocal(QNameToStatementDefinition.class))
79 .addSupport(sourceLocal(BelongsToPrefixToModuleName.class)).build();
82 private static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle
83 .derivedFrom(LINKAGE_BUNDLE)
84 .addSupport(new YinElementStatementImpl.Definition())
85 .addSupport(new ArgumentStatementImpl.Definition())
86 .addSupport(new ExtensionStatementImpl.Definition())
87 .addSupport(global(ExtensionNamespace.class))
88 .addSupport(new TypedefStatementImpl.Definition())
89 .addSupport(treeScoped(TypeNamespace.class))
90 .addSupport(new IdentityStatementImpl.Definition())
91 .addSupport(global(IdentityNamespace.class))
92 .addSupport(new DefaultStatementImpl.Definition())
93 .addSupport(new StatusStatementImpl.Definition())
94 .addSupport(new TypeStatementImpl.Definition())
95 .addSupport(new UnitsStatementImpl.Definition())
96 .addSupport(new RequireInstanceStatementImpl.Definition())
97 .addSupport(new BitStatementImpl.Definition())
98 .addSupport(new PathStatementImpl.Definition())
99 .addSupport(new EnumStatementImpl.Definition())
100 .addSupport(new LengthStatementImpl.Definition())
101 .addSupport(new PatternStatementImpl.Definition())
102 .addSupport(new RangeStatementImpl.Definition())
103 .addSupport(new ContainerStatementImpl.Definition())
104 .addSupport(new GroupingStatementImpl.Definition())
105 .addSupport(new ListStatementImpl.Definition())
106 .addSupport(new UniqueStatementImpl.Definition())
107 .addSupport(new RpcStatementImpl.Definition())
108 .addSupport(new InputStatementImpl.Definition())
109 .addSupport(new OutputStatementImpl.Definition())
110 .addSupport(new NotificationStatementImpl.Definition())
111 .addSupport(new FractionDigitsStatementImpl.Definition())
112 .addSupport(new BaseStatementImpl.Definition())
113 .addSupport(global(DerivedIdentitiesNamespace.class))
116 private static final StatementSupportBundle FULL_DECL_BUNDLE = StatementSupportBundle
117 .derivedFrom(STMT_DEF_BUNDLE)
118 .addSupport(new LeafStatementImpl.Definition())
119 .addSupport(new ConfigStatementImpl.Definition())
120 .addSupport(new DeviationStatementImpl.Definition())
121 .addSupport(new DeviateStatementImpl.Definition())
122 .addSupport(new ChoiceStatementImpl.Definition())
123 .addSupport(new CaseStatementImpl.Definition())
124 .addSupport(new MustStatementImpl.Definition())
125 .addSupport(new MandatoryStatementImpl.Definition())
126 .addSupport(new AnyxmlStatementImpl.Definition())
127 .addSupport(new IfFeatureStatementImpl.Definition())
128 .addSupport(new UsesStatementImpl.Definition())
129 .addSupport(treeScoped(GroupingNamespace.class)) //treeScoped
130 .addSupport(new ErrorMessageStatementImpl.Definition())
131 .addSupport(new ErrorAppTagStatementImpl.Definition())
132 .addSupport(new LeafListStatementImpl.Definition())
133 .addSupport(new PresenceStatementImpl.Definition())
134 .addSupport(new KeyStatementImpl.Definition())
135 .addSupport(new MaxElementsStatementImpl.Definition())
136 .addSupport(new MinElementsStatementImpl.Definition())
137 .addSupport(new OrderedByStatementImpl.Definition())
138 .addSupport(new WhenStatementImpl.Definition())
139 .addSupport(new AugmentStatementImpl.Definition())
140 .addSupport(new RefineStatementImpl.Definition())
141 .addSupport(new FeatureStatementImpl.Definition())
142 .addSupport(new PositionStatementImpl.Definition())
143 .addSupport(new ValueStatementImpl.Definition())
146 public static final Map<ModelProcessingPhase, StatementSupportBundle> RFC6020_BUNDLES = ImmutableMap
147 .<ModelProcessingPhase, StatementSupportBundle> builder()
148 .put(ModelProcessingPhase.SOURCE_LINKAGE, LINKAGE_BUNDLE)
149 .put(ModelProcessingPhase.STATEMENT_DEFINITION, STMT_DEF_BUNDLE)
150 .put(ModelProcessingPhase.FULL_DECLARATION, FULL_DECL_BUNDLE)
151 .put(ModelProcessingPhase.EFFECTIVE_MODEL, FULL_DECL_BUNDLE)
154 public static final CrossSourceStatementReactor RFC6020_REACTOR = CrossSourceStatementReactor
156 .setBundle(ModelProcessingPhase.INIT, INIT_BUNDLE)
157 .setBundle(ModelProcessingPhase.SOURCE_LINKAGE, LINKAGE_BUNDLE)
158 .setBundle(ModelProcessingPhase.STATEMENT_DEFINITION,
160 .setBundle(ModelProcessingPhase.FULL_DECLARATION, FULL_DECL_BUNDLE)
161 .setBundle(ModelProcessingPhase.EFFECTIVE_MODEL, FULL_DECL_BUNDLE)
162 .setValidationBundle(
163 ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS,
164 YangValidationBundles.SUPPORTED_REFINE_SUBSTATEMENTS)
165 .setValidationBundle(ValidationBundleType.SUPPORTED_AUGMENT_TARGETS,
166 YangValidationBundles.SUPPORTED_AUGMENT_TARGETS)
167 .setValidationBundle(ValidationBundleType.SUPPORTED_CASE_SHORTHANDS,
168 YangValidationBundles.SUPPORTED_CASE_SHORTHANDS)
169 .setValidationBundle(ValidationBundleType.SUPPORTED_DATA_NODES,
170 YangValidationBundles.SUPPORTED_DATA_NODES)
173 private YangInferencePipeline() {
174 throw new UnsupportedOperationException("Utility class");