Use moved BindingReflections
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / md / sal / binding / impl / BindingDOMNotificationListenerAdapter.java
index 668030e1a6f00572c7862d5a93f019f2d78eeed6..9e5b8ccf3d3d7224e36f05b27b0d83d0326aa36c 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.md.sal.binding.impl;
 
 import com.google.common.collect.ImmutableMap;
+import com.google.common.reflect.TypeToken;
 import java.lang.reflect.Method;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -16,11 +17,11 @@ import java.util.Set;
 import javax.annotation.Nonnull;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
-import org.opendaylight.yangtools.binding.data.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.binding.dom.adapter.invoke.NotificationListenerInvoker;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
-import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
-import org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
@@ -30,7 +31,8 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
     private final NotificationListener delegate;
     private final Map<SchemaPath,NotificationListenerInvoker> invokers;
 
-    public BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final NotificationListener delegate) {
+    BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec,
+            final NotificationListener delegate) {
         this.codec = codec;
         this.delegate = delegate;
         this.invokers = createInvokerMapFor(delegate.getClass());
@@ -44,7 +46,7 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
     }
 
     private Notification deserialize(final DOMNotification notification) {
-        if(notification instanceof LazySerializedDOMNotification) {
+        if (notification instanceof LazySerializedDOMNotification) {
             return ((LazySerializedDOMNotification) notification).getBindingData();
         }
         return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
@@ -58,14 +60,17 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
         return invokers.keySet();
     }
 
-    private static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
+    public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
+            final Class<? extends NotificationListener> implClz) {
         final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
-        for(final Class<?> iface : implClz.getInterfaces()) {
-            if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
+        for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
+            Class<?> iface = ifaceToken.getRawType();
+            if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
                 @SuppressWarnings("unchecked")
-                final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
+                final Class<? extends NotificationListener> listenerType =
+                        (Class<? extends NotificationListener>) iface;
                 final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
-                for(final SchemaPath path : getNotificationTypes(listenerType)) {
+                for (final SchemaPath path : getNotificationTypes(listenerType)) {
                     builder.put(path, invoker);
                 }
             }
@@ -77,8 +82,8 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
         // TODO: Investigate possibility and performance impact if we cache this or expose
         // it from NotificationListenerInvoker
         final Set<SchemaPath> ret = new HashSet<>();
-        for(final Method method : type.getMethods()) {
-            if(BindingReflections.isNotificationCallback(method)) {
+        for (final Method method : type.getMethods()) {
+            if (BindingReflections.isNotificationCallback(method)) {
                 final Class<?> notification = method.getParameterTypes()[0];
                 final QName name = BindingReflections.findQName(notification);
                 ret.add(SchemaPath.create(true, name));
@@ -86,4 +91,4 @@ class BindingDOMNotificationListenerAdapter implements DOMNotificationListener {
         }
         return ret;
     }
-}
\ No newline at end of file
+}