Add AbstractRegistration.notClosed() 71/88171/1
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 29 Feb 2020 11:17:07 +0000 (12:17 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 29 Feb 2020 15:46:31 +0000 (16:46 +0100)
This is a utility method useful for stream integration.

Change-Id: I6408cc25a1a10f010fc4f42ee83d50db31ca8bfa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractRegistration.java

index f0e6238e339a54dc52f1b576ac22e601f5509178..85db99a72d6b3ac79cbd14fd9a645e213bdb652e 100644 (file)
@@ -27,7 +27,7 @@ public abstract class AbstractRegistration implements Registration {
     protected abstract void removeRegistration();
 
     /**
-     * Query the state of this registration. Returns true if it was closed.
+     * Query the state of this registration. Returns true if it was closed. Equivalent of {@code !notClosed()}.
      *
      * @return true if the registration was closed, false otherwise.
      */
@@ -35,6 +35,15 @@ public abstract class AbstractRegistration implements Registration {
         return closed != 0;
     }
 
+    /**
+     * Query the state of this registration. Returns false if it was closed. Equivalent of {@code !isClosed()}.
+     *
+     * @return false if the registration was closed, true otherwise.
+     */
+    public final boolean notClosed() {
+        return closed == 0;
+    }
+
     @Override
     public final void close() {
         if (CLOSED_UPDATER.compareAndSet(this, 0, 1)) {