BUG-4688: Add flexible match support to NamespaceStorageSupport
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / VirtualNamespaceContext.java
index 7db50e0199f57112e33516bc6aeb0671a580aa98..2df2fe5d36bd5f40f01c061f5f7a6a59f1ec6a71 100644 (file)
@@ -11,31 +11,29 @@ import com.google.common.collect.HashMultimap;
 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);
     }