import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBehaviourRegistry {
+final class BuildGlobalContext extends NamespaceStorageSupport {
private static final Logger LOG = LoggerFactory.getLogger(BuildGlobalContext.class);
private static final ModelProcessingPhase[] PHASE_EXECUTION_ORDER = {
}
@Override
- NamespaceBehaviourRegistry getBehaviourRegistry() {
- return this;
- }
-
- @Override
- public <K, V> NamespaceBehaviourWithListeners<K, V> getNamespaceBehaviour(final ParserNamespace<K, V> type) {
+ <K, V> NamespaceBehaviourWithListeners<K, V> getNamespaceBehaviour(final ParserNamespace<K, V> type) {
NamespaceBehaviourWithListeners<?, ?> potential = supportedNamespaces.get(type);
if (potential == null) {
final var potentialRaw = verifyNotNull(supports.get(currentPhase)).namespaceBehaviourOf(type);
+++ /dev/null
-/*
- * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.parser.stmt.reactor;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceNotAvailableException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
-
-/**
- * An entity able to look up a {@link NamespaceBehaviour} corresponding to a {@link ParserNamespace}.
- */
-sealed interface NamespaceBehaviourRegistry permits BuildGlobalContext, SourceSpecificContext {
- /**
- * Get a namespace behavior.
- *
- * @param <K> key type
- * @param <V> value type
- * @param namespace Namespace type
- * @return Namespace behaviour
- * @throws NamespaceNotAvailableException when the namespace is not available
- * @throws NullPointerException if {@code namespace} is {@code null}
- */
- <K, V> @NonNull NamespaceBehaviour<K, V> getNamespaceBehaviour(ParserNamespace<K, V> namespace);
-}
import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceNotAvailableException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.slf4j.Logger;
public abstract NamespaceStorageNode getParentNamespaceStorage();
/**
- * Return the registry of a source context.
+ * Get a namespace behavior.
*
- * @return registry of source context
+ * @param <K> key type
+ * @param <V> value type
+ * @param namespace Namespace type
+ * @return Namespace behaviour
+ * @throws NamespaceNotAvailableException when the namespace is not available
+ * @throws NullPointerException if {@code namespace} is {@code null}
*/
- abstract @NonNull NamespaceBehaviourRegistry getBehaviourRegistry();
+ abstract <K, V> @NonNull NamespaceBehaviour<K, V> getNamespaceBehaviour(ParserNamespace<K, V> namespace);
// FIXME: 8.0.0: do we really need this method?
final void checkLocalNamespaceAllowed(final ParserNamespace<?, ?> type) {
}
final <K, V> Map<K, V> getNamespace(final ParserNamespace<K, V> type) {
- return getBehaviourRegistry().getNamespaceBehaviour(type).getAllFrom(this);
+ return getNamespaceBehaviour(type).getAllFrom(this);
}
@SuppressWarnings("unchecked")
final <K, V, T extends K, U extends V> void addToNamespace(final ParserNamespace<K, V> type, final T key,
final U value) {
- getBehaviourRegistry().getNamespaceBehaviour(type).addTo(this, key, value);
+ getNamespaceBehaviour(type).addTo(this, key, value);
}
@Override
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.ExecutionOrder;
+import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementFactory;
public abstract Collection<? extends @NonNull StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements();
@Override
- final NamespaceBehaviourRegistry getBehaviourRegistry() {
- return getRoot().getBehaviourRegistryImpl();
+ final <K, V> NamespaceBehaviour<K, V> getNamespaceBehaviour(final ParserNamespace<K, V> type) {
+ return getRoot().getSourceContext().getNamespaceBehaviour(type);
}
@Override
@Override
public final <K, V> V namespaceItem(final ParserNamespace<K, V> namespace, final K key) {
- return getBehaviourRegistry().getNamespaceBehaviour(namespace).getFrom(this, key);
+ return getNamespaceBehaviour(namespace).getFrom(this, key);
}
@Override
return this;
}
- SourceSpecificContext getSourceContext() {
+ @NonNull SourceSpecificContext getSourceContext() {
return sourceContext;
}
rootIdentifier = requireNonNull(identifier);
}
- @NonNull NamespaceBehaviourRegistry getBehaviourRegistryImpl() {
- return sourceContext;
- }
-
@NonNull YangVersion getRootVersionImpl() {
return rootVersion == null ? DEFAULT_VERSION : rootVersion;
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBehaviourRegistry, Mutable {
+final class SourceSpecificContext implements NamespaceStorageNode, Mutable {
enum PhaseCompletionProgress {
NO_PROGRESS,
PROGRESS,
return null;
}
- @Override
- public <K, V> NamespaceBehaviour<K, V> getNamespaceBehaviour(final ParserNamespace<K, V> type) {
+ <K, V> NamespaceBehaviour<K, V> getNamespaceBehaviour(final ParserNamespace<K, V> type) {
if (StatementSupport.NAMESPACE.equals(type)) {
@SuppressWarnings("unchecked")
final var ret = (NamespaceBehaviour<K, V>) statementSupports;
private <K, V> Optional<Entry<K, V>> getFromNamespace(final ParserNamespace<K, V> type,
final NamespaceKeyCriterion<K> criterion) {
- return getBehaviourRegistry().getNamespaceBehaviour(type).getFrom(this, criterion);
+ return getNamespaceBehaviour(type).getFrom(this, criterion);
}
final <K, V> void waitForPhase(final Object value, final ParserNamespace<K, V> type,
}
private <K, V> NamespaceBehaviourWithListeners<K, V> getBehaviour(final ParserNamespace<K, V> type) {
- final NamespaceBehaviour<K, V> behaviour = getBehaviourRegistry().getNamespaceBehaviour(type);
+ final NamespaceBehaviour<K, V> behaviour = getNamespaceBehaviour(type);
checkArgument(behaviour instanceof NamespaceBehaviourWithListeners, "Namespace %s does not support listeners",
type);
@Override
public final <K, KT extends K, C extends StmtContext<?, ?, ?>> void addContext(
final ParserNamespace<K, ? super C> namespace, final KT key, final C stmt) {
- getBehaviourRegistry().getNamespaceBehaviour(namespace).addTo(this, key, stmt);
+ getNamespaceBehaviour(namespace).addTo(this, key, stmt);
}
@Override