import com.google.common.collect.Multimap;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour;
-import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
-final class VirtualNamespaceContext<K, V, N extends IdentifierNamespace<K, V>, DK>
+final class VirtualNamespaceContext<K, V, N extends IdentifierNamespace<K, V>, D>
extends NamespaceBehaviourWithListeners<K, V, N> {
- private final Multimap<DK, ValueAddedListener<K>> listeners = HashMultimap.create();
- private final DerivedNamespaceBehaviour<K, V, DK, N, ?> derivedDelegate;
+ private final Multimap<D, KeyedValueAddedListener<K>> listeners = HashMultimap.create();
+ private final DerivedNamespaceBehaviour<K, V, D, N, ?> derivedDelegate;
- VirtualNamespaceContext(final DerivedNamespaceBehaviour<K, V, DK, N, ?> delegate) {
+ VirtualNamespaceContext(final DerivedNamespaceBehaviour<K, V, D, N, ?> delegate) {
super(delegate);
this.derivedDelegate = delegate;
}
@Override
- protected boolean isRequestedValue(final ValueAddedListener<K> listener, final NamespaceStorageNode storage,
- final V value) {
- return value == getFrom(listener.getCtxNode(), listener.getKey());
+ void addListener(final KeyedValueAddedListener<K> listener) {
+ listeners.put(derivedDelegate.getSignificantKey(listener.getKey()), listener);
}
@Override
- protected void addListener(final K key, final ValueAddedListener<K> listener) {
- listeners.put(derivedDelegate.getSignificantKey(key), listener);
+ void addListener(final PredicateValueAddedListener<K, V> listener) {
+ throw new UnsupportedOperationException("Virtual namespaces support only exact lookups");
}
- void addedToSourceNamespace(final NamespaceBehaviour.NamespaceStorageNode storage, final DK key, final V value) {
+ void addedToSourceNamespace(final NamespaceStorageNode storage, final D key, final V value) {
notifyListeners(storage, listeners.get(key).iterator(), value);
}