Add NoOp{Listener,Object}Registration
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / NoOpListenerRegistration.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.yangtools.concepts;
9
10 import com.google.common.annotations.Beta;
11 import java.util.EventListener;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13
14 /**
15  * Implementation of {@link ListenerRegistration} which does nothing in its {@link #close()} method.
16  *
17  * @param <T> Type of registered listener
18  */
19 @Beta
20 @NonNullByDefault
21 public final class NoOpListenerRegistration<T extends EventListener> extends NoOpObjectRegistration<T>
22         implements ListenerRegistration<T> {
23     private NoOpListenerRegistration(final T instance) {
24         super(instance);
25     }
26
27     public static <T extends EventListener> ListenerRegistration<T> of(final T instance) {
28         return new NoOpListenerRegistration<>(instance);
29     }
30 }