Merge "BUG-46: preliminary switch to MD-SAL"
[bgpcep.git] / concepts / src / main / java / org / opendaylight / protocol / concepts / ListenerRegistration.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.protocol.concepts;
9
10 import java.util.EventListener;
11
12 import javax.annotation.concurrent.ThreadSafe;
13
14 import com.google.common.base.Preconditions;
15
16 /**
17  * An interface representing a listener registration. Objects offering
18  * the ability to register listener should return an implementation of this
19  * interface upon successful registration. The users are required to call
20  * #close() before losing the reference to that object.
21  *
22  * @param <T> template reference to associated EventListener implementation
23  */
24 @ThreadSafe
25 public abstract class ListenerRegistration<T extends EventListener> extends AbstractRegistration {
26         protected final T listener;
27
28         protected ListenerRegistration(final T listener) {
29                 this.listener = Preconditions.checkNotNull(listener);
30         }
31
32         /**
33          * Access the listener object associated with this registration.
34          *
35          * @return Associated listener.
36          */
37         public final T getListener() {
38                 return listener;
39         }
40 }
41