2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.core.compat;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ForwardingObject;
13 import java.util.Arrays;
14 import java.util.Collection;
15 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationService;
16 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
17 import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
18 import org.opendaylight.yangtools.concepts.ListenerRegistration;
19 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
22 public class DOMNotificationServiceAdapter extends ForwardingObject
23 implements org.opendaylight.mdsal.dom.api.DOMNotificationService {
25 private final DOMNotificationService delegate;
27 public DOMNotificationServiceAdapter(final DOMNotificationService delegate) {
28 this.delegate = requireNonNull(delegate);
32 public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
33 final Collection<SchemaPath> types) {
34 // Controller events are sub-interfaces of MD-SAL events, hence direct routing is okay
35 final ListenerRegistration<?> reg = delegate().registerNotificationListener(listener::onNotification, types);
37 return new AbstractListenerRegistration<T>(listener) {
39 protected void removeRegistration() {
47 public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
48 final SchemaPath... types) {
49 return registerNotificationListener(listener, Arrays.asList(types));
53 protected DOMNotificationService delegate() {