+ /**
+ * A handle to a registered {@link DOMDataTreeChangeListener}. Implementations of this interface are guaranteed to
+ * use identity-based equality.
+ */
+ @NonNullByDefault
+ protected sealed interface Reg permits RegImpl {
+ /**
+ * Return the underlying listener.
+ *
+ * @return the underlying listener
+ */
+ DOMDataTreeChangeListener listener();
+
+ /**
+ * Check if this handle has not been closed yet.
+ *
+ * @return {@code true} if this handle is still open
+ */
+ boolean notClosed();
+ }
+
+ /**
+ * Registration handle for a {@link DOMDataTreeChangeListener}. This class is exposed to subclasses only as a
+ * convenience, so they can use its identity-based equality while at the same time having access to the listener.
+ *
+ * <p>
+ * Implementations must not invoke {@link #close()} nor should otherwise interact with the registration.
+ */
+ @NonNullByDefault
+ final class RegImpl extends AbstractObjectRegistration<DOMDataTreeChangeListener> implements Reg {
+ private RegImpl(final DOMDataTreeChangeListener instance) {
+ super(instance);
+ }
+
+ @Override
+ public DOMDataTreeChangeListener listener() {
+ return getInstance();
+ }
+
+ @Override
+ protected void removeRegistration() {
+ registrationRemoved(this);
+ }
+ }
+