import javax.annotation.concurrent.ThreadSafe;
/**
- * Utility registration handle. It is a convenience for register-style method
- * which can return an AutoCloseable realized by a subclass of this class.
- * Invoking the close() method triggers unregistration of the state the method
- * installed.
+ * Utility registration handle. It is a convenience for register-style method which can return an AutoCloseable realized
+ * by a subclass of this class. Invoking the close() method triggers unregistration of the state the method installed.
*/
@ThreadSafe
public abstract class AbstractRegistration implements AutoCloseable {
- @GuardedBy("this")
- private boolean closed = false;
+ @GuardedBy("this")
+ private boolean closed = false;
- /**
- * Remove the state referenced by this registration. This method is
- * guaranteed to be called at most once. The referenced state must be
- * retained until this method is invoked.
- */
- protected abstract void removeRegistration();
+ /**
+ * Remove the state referenced by this registration. This method is guaranteed to be called at most once. The
+ * referenced state must be retained until this method is invoked.
+ */
+ protected abstract void removeRegistration();
- @Override
- public final synchronized void close() {
- if (!closed) {
- closed = true;
- removeRegistration();
- }
- }
+ @Override
+ public final synchronized void close() {
+ if (!closed) {
+ closed = true;
+ removeRegistration();
+ }
+ }
}