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.yangtools.concepts;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.MoreObjects;
14 import org.eclipse.jdt.annotation.NonNullByDefault;
17 * Implementation of {@link ObjectRegistration} which does nothing in its {@link #close()} method.
19 * @param <T> Type of registered object
23 public class NoOpObjectRegistration<T> implements Immutable, ObjectRegistration<T> {
24 private final T instance;
26 NoOpObjectRegistration(final T instance) {
27 this.instance = requireNonNull(instance);
30 public static <T> ObjectRegistration<T> of(final T instance) {
31 return new NoOpObjectRegistration<>(instance);
35 public final T getInstance() {
40 public final void close() {
45 public final String toString() {
46 return MoreObjects.toStringHelper(this).add("instance", instance).toString();