From 9a98b1d801dc6ec037b468f06e116f60e3da3a36 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 29 Feb 2020 12:17:07 +0100 Subject: [PATCH] Add AbstractRegistration.notClosed() This is a utility method useful for stream integration. Change-Id: I6408cc25a1a10f010fc4f42ee83d50db31ca8bfa Signed-off-by: Robert Varga --- .../yangtools/concepts/AbstractRegistration.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractRegistration.java b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractRegistration.java index 7f43bc9f4b..ae2677b0e2 100644 --- a/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractRegistration.java +++ b/common/concepts/src/main/java/org/opendaylight/yangtools/concepts/AbstractRegistration.java @@ -38,7 +38,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. */ @@ -46,6 +46,15 @@ public abstract class AbstractRegistration implements Registration { return (byte) CLOSED.getAcquire(this) != 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 (byte) CLOSED.getAcquire(this) == 0; + } + @Override public final void close() { // We want full setVolatile() memory semantics here, as all state before calling this method -- 2.36.6