From: David ‘Bombe’ Roden Date: Sat, 10 Feb 2024 08:16:05 +0000 (+0100) Subject: ✨ Allow triggering states from anywhere X-Git-Tag: v2~37 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=cb9511aa55950a41878bcbc068800acfa0325a3d;p=rhynodge.git ✨ Allow triggering states from anywhere --- 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} */