2 * Copyright (c) 2014 Cisco Systems, Inc. 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.md.sal.binding.compat;
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.sal.binding.api.NotificationListener;
12 import org.opendaylight.yangtools.yang.binding.Notification;
15 * An aggregated listener registration. This is a result of registering an invoker which can handle multiple
16 * interfaces at the same time. In order to support correct delivery, we need to maintain per-type registrations
17 * which get squashed if a notification which implements multiple interfaces is encountered.
19 * We take care of that by implementing alternate {@link #hashCode()}/{@link #equals(Object)}, which resolve
20 * to the backing aggregator.
22 * @param <N> Notification type
23 * @param <A> Aggregator type
25 abstract class AggregatedNotificationListenerRegistration<N extends Notification, A> extends AbstractNotificationListenerRegistration<N> {
26 private final A aggregator;
28 protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type, final NotificationListener<N> listener, final A aggregator) {
29 super(type, listener);
30 this.aggregator = Preconditions.checkNotNull(aggregator);
33 protected A getAggregator() {
38 public int hashCode() {
39 return aggregator.hashCode();
43 public boolean equals(final Object obj) {
50 if (!this.getClass().equals(obj.getClass())) {
54 return aggregator.equals(((AggregatedNotificationListenerRegistration<?, ?>)obj).aggregator);