956783130caf10cf7b2b2ae45b854b93b871e72e
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / GenericNotificationRegistration.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.impl;
9
10 import org.opendaylight.controller.sal.binding.api.NotificationListener;
11 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13 import org.opendaylight.yangtools.yang.binding.Notification;
14
15 public class GenericNotificationRegistration<T extends Notification> extends AbstractObjectRegistration<NotificationListener<T>> implements ListenerRegistration<NotificationListener<T>> {
16     private final Class<T> _type;
17
18     public Class<T> getType() {
19         return this._type;
20     }
21
22     private NotificationBrokerImpl notificationBroker;
23
24     public GenericNotificationRegistration(final Class<T> type, final NotificationListener<T> instance, final NotificationBrokerImpl broker) {
25         super(instance);
26         this._type = type;
27         this.notificationBroker = broker;
28     }
29
30     @Override
31     protected void removeRegistration() {
32         this.notificationBroker.unregisterListener(this);
33         this.notificationBroker = null;
34     }
35 }