Add ability to get yang sources from SchemaContext.
[yangtools.git] / concepts / src / main / java / org / opendaylight / yangtools / concepts / AbstractObjectRegistration.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.yangtools.concepts;
9
10 /**
11  * Utility registration handle. It is a convenience for register-style method
12  * which can return an AutoCloseable realized by a subclass of this class.
13  * Invoking the close() method triggers unregistration of the state the method
14  * installed.
15  */
16 public abstract class AbstractObjectRegistration<T> extends AbstractRegistration implements ObjectRegistration<T> {
17     private final T instance;
18
19     protected AbstractObjectRegistration(final T instance) {
20         this.instance = instance;
21     }
22
23     @Override
24     public final T getInstance() {
25         return instance;
26     }
27
28
29     @Override
30     public String toString() {
31         return "AbstractObjectRegistration{" +
32                 "instance=" + instance +
33                 '}';
34     }
35 }
36