package org.opendaylight.yangtools.yang.parser.stmt.reactor;
import static com.google.common.base.Preconditions.checkState;
+import static com.google.common.base.Verify.verifyNotNull;
import static java.util.Objects.requireNonNull;
import com.google.common.base.Verify;
import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
addToNamespace(ValidationBundlesNamespace.class, supportedValidation);
- this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
+ supportedVersions = ImmutableSet.copyOf(
+ verifyNotNull(supports.get(ModelProcessingPhase.INIT)).getSupportedVersions());
}
StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase phase) {
final Class<N> type) {
NamespaceBehaviourWithListeners<?, ?, ?> potential = supportedNamespaces.get(type);
if (potential == null) {
- final NamespaceBehaviour<K, V, N> potentialRaw = supports.get(currentPhase).getNamespaceBehaviour(type);
+ final var potentialRaw = verifyNotNull(supports.get(currentPhase)).getNamespaceBehaviour(type);
if (potentialRaw != null) {
potential = createNamespaceContext(potentialRaw);
supportedNamespaces.put(type, potential);
StatementDefinitionContext<?, ?, ?> getStatementDefinition(final YangVersion version, final QName name) {
StatementDefinitionContext<?, ?, ?> potential = definitions.get(version, name);
if (potential == null) {
- final StatementSupport<?, ?, ?> potentialRaw = supports.get(currentPhase).getStatementDefinition(version,
- name);
+ final var potentialRaw = verifyNotNull(supports.get(currentPhase)).getStatementDefinition(version, name);
if (potentialRaw != null) {
potential = new StatementDefinitionContext<>(potentialRaw);
definitions.put(version, name, potential);
*/
package org.opendaylight.yangtools.yang.parser.rfc7950.reactor;
+import static com.google.common.base.Verify.verifyNotNull;
+
import com.google.common.annotations.Beta;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Table;
public @NonNull CustomCrossSourceStatementReactorBuilder addStatementSupport(final ModelProcessingPhase phase,
final StatementSupport<?, ?, ?> stmtSupport) {
- reactorSupportBundles.get(phase).addSupport(stmtSupport);
+ getBuilder(phase).addSupport(stmtSupport);
return this;
}
public @NonNull CustomCrossSourceStatementReactorBuilder overrideStatementSupport(final ModelProcessingPhase phase,
final StatementSupport<?, ?, ?> stmtSupport) {
- reactorSupportBundles.get(phase).overrideSupport(stmtSupport);
+ getBuilder(phase).overrideSupport(stmtSupport);
return this;
}
public @NonNull CustomCrossSourceStatementReactorBuilder addNamespaceSupport(final ModelProcessingPhase phase,
final NamespaceBehaviour<?, ?, ?> namespaceSupport) {
- reactorSupportBundles.get(phase).addSupport(namespaceSupport);
+ getBuilder(phase).addSupport(namespaceSupport);
return this;
}
* @return A CrossSourceStatementReactor
*/
public @NonNull CrossSourceStatementReactor build() {
- final StatementSupportBundle initBundle = reactorSupportBundles.get(ModelProcessingPhase.INIT).build();
- final StatementSupportBundle preLinkageBundle = reactorSupportBundles
- .get(ModelProcessingPhase.SOURCE_PRE_LINKAGE).setParent(initBundle).build();
- final StatementSupportBundle linkageBundle = reactorSupportBundles.get(ModelProcessingPhase.SOURCE_LINKAGE)
- .setParent(preLinkageBundle).build();
- final StatementSupportBundle stmtDefBundle = reactorSupportBundles
- .get(ModelProcessingPhase.STATEMENT_DEFINITION).setParent(linkageBundle).build();
- final StatementSupportBundle fullDeclBundle = reactorSupportBundles.get(ModelProcessingPhase.FULL_DECLARATION)
- .setParent(stmtDefBundle).build();
- final StatementSupportBundle effectiveBundle = reactorSupportBundles.get(ModelProcessingPhase.EFFECTIVE_MODEL)
- .setParent(fullDeclBundle).build();
+ final StatementSupportBundle initBundle = getBuilder(ModelProcessingPhase.INIT).build();
+ final StatementSupportBundle preLinkageBundle = getBuilder(ModelProcessingPhase.SOURCE_PRE_LINKAGE)
+ .setParent(initBundle).build();
+ final StatementSupportBundle linkageBundle = getBuilder(ModelProcessingPhase.SOURCE_LINKAGE)
+ .setParent(preLinkageBundle).build();
+ final StatementSupportBundle stmtDefBundle = getBuilder(ModelProcessingPhase.STATEMENT_DEFINITION)
+ .setParent(linkageBundle).build();
+ final StatementSupportBundle fullDeclBundle = getBuilder(ModelProcessingPhase.FULL_DECLARATION)
+ .setParent(stmtDefBundle).build();
+ final StatementSupportBundle effectiveBundle = getBuilder(ModelProcessingPhase.EFFECTIVE_MODEL)
+ .setParent(fullDeclBundle).build();
final CrossSourceStatementReactor.Builder reactorBuilder = CrossSourceStatementReactor.builder()
.setBundle(ModelProcessingPhase.INIT, initBundle)
return reactorBuilder.build();
}
+
+ private StatementSupportBundle.@NonNull Builder getBuilder(final ModelProcessingPhase phase) {
+ return verifyNotNull(reactorSupportBundles.get(phase));
+ }
}