import java.util.LinkedList;
import java.util.List;
-import java.util.Optional;
+import java.util.function.Predicate;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.api.xml.XmlUtil;
-import org.opendaylight.netconf.sal.connect.api.MessageTransformer;
+import org.opendaylight.netconf.sal.connect.api.NotificationTransformer;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.slf4j.Logger;
final class NotificationHandler {
private static final Logger LOG = LoggerFactory.getLogger(NotificationHandler.class);
- private final RemoteDeviceHandler<?> salFacade;
+ private final RemoteDeviceHandler salFacade;
// FIXME: better implementation?
private final List<NetconfMessage> queue = new LinkedList<>();
private final RemoteDeviceId id;
private boolean passNotifications = false;
private NotificationFilter filter;
- private MessageTransformer messageTransformer;
+ private NotificationTransformer messageTransformer;
- NotificationHandler(final RemoteDeviceHandler<?> salFacade, final RemoteDeviceId id) {
+ NotificationHandler(final RemoteDeviceHandler salFacade, final RemoteDeviceId id) {
this.salFacade = requireNonNull(salFacade);
this.id = requireNonNull(id);
}
* Forward all cached notifications and pass all notifications from this point directly to sal facade.
* @param transformer Message transformer
*/
- synchronized void onRemoteSchemaUp(final MessageTransformer transformer) {
+ synchronized void onRemoteSchemaUp(final NotificationTransformer transformer) {
messageTransformer = requireNonNull(transformer);
passNotifications = true;
private synchronized void passNotification(final DOMNotification parsedNotification) {
LOG.debug("{}: Forwarding notification {}", id, parsedNotification);
- if (filter == null || filter.filterNotification(parsedNotification).isPresent()) {
+ if (filter == null || filter.test(parsedNotification)) {
salFacade.onNotification(parsedNotification);
}
}
messageTransformer = null;
}
- interface NotificationFilter {
+ @FunctionalInterface
+ interface NotificationFilter extends Predicate<DOMNotification> {
- Optional<DOMNotification> filterNotification(DOMNotification notification);
}
}