From cb9511aa55950a41878bcbc068800acfa0325a3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 10 Feb 2024 09:16:05 +0100 Subject: [PATCH 1/1] =?utf8?q?=E2=9C=A8=20Allow=20triggering=20states=20fr?= =?utf8?q?om=20anywhere?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/rhynodge/State.java | 9 ++++++--- .../java/net/pterodactylus/rhynodge/states/AbstractState.java | 11 +++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/State.java b/src/main/java/net/pterodactylus/rhynodge/State.java index 2a8ba1c..966dbe3 100644 --- a/src/main/java/net/pterodactylus/rhynodge/State.java +++ b/src/main/java/net/pterodactylus/rhynodge/State.java @@ -55,9 +55,12 @@ public interface State { * @return {@code true} if this state triggers a change notification, * {@code false} otherwise */ - default boolean triggered() { - return false; - } + boolean triggered(); + + /** + * Sets whether this state will trigger a notification. + */ + void trigger(); boolean isEmpty(); diff --git a/src/main/java/net/pterodactylus/rhynodge/states/AbstractState.java b/src/main/java/net/pterodactylus/rhynodge/states/AbstractState.java index f3b37e5..ecd520f 100644 --- a/src/main/java/net/pterodactylus/rhynodge/states/AbstractState.java +++ b/src/main/java/net/pterodactylus/rhynodge/states/AbstractState.java @@ -49,6 +49,7 @@ public abstract class AbstractState implements State { @JsonProperty private final boolean success; private final boolean empty; + private boolean triggered = false; /** The optional exception that occured while retrieving the state. */ private final Throwable exception; @@ -167,6 +168,16 @@ public abstract class AbstractState implements State { return empty; } + @Override + public boolean triggered() { + return triggered; + } + + @Override + public void trigger() { + triggered = true; + } + /** * {@inheritDoc} */ -- 2.7.4