2 * Copyright (c) 2013 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.yangtools.concepts;
10 import com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
14 * Utility registration handle. It is a convenience for register-style method
15 * which can return an AutoCloseable realized by a subclass of this class.
16 * Invoking the close() method triggers unregistration of the state the method
19 public abstract class AbstractObjectRegistration<T> extends AbstractRegistration implements ObjectRegistration<T> {
20 private final T instance;
22 protected AbstractObjectRegistration(final @Nonnull T instance) {
23 this.instance = Preconditions.checkNotNull(instance);
27 public final T getInstance() {
32 public String toString() {
33 return "AbstractObjectRegistration{instance=" + instance + '}';