From: David ‘Bombe’ Roden Date: Wed, 2 Jan 2013 10:13:42 +0000 (+0100) Subject: Try to bind together queries, triggers, and actions. X-Git-Tag: 0.1~119 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=ed9b0797c5dcc85c57a93fde0ee6ad1156f0ffe2;p=rhynodge.git Try to bind together queries, triggers, and actions. --- diff --git a/src/main/java/net/pterodactylus/reactor/Reaction.java b/src/main/java/net/pterodactylus/reactor/Reaction.java new file mode 100644 index 0000000..0e0b359 --- /dev/null +++ b/src/main/java/net/pterodactylus/reactor/Reaction.java @@ -0,0 +1,110 @@ +/* + * Reactor - Reaction.java - Copyright © 2013 David Roden + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.pterodactylus.reactor; + +/** + * A {@code Reaction} binds together {@link Query}s, {@link Trigger}s, and + * {@link Action}s, and it stores the intermediary {@link State}s. + * + * @param + * The type of the state + * @author David ‘Bombe’ Roden + */ +public class Reaction { + + /** The query to run. */ + private final Query query; + + /** The trigger to detect changes. */ + private final Trigger trigger; + + /** The action to perform. */ + private final Action action; + + /** The current state of the query. */ + private S currentState; + + /** The previous state of the query. */ + private S previousState; + + /** + * Creates a new reaction. + * + * @param query + * The query to run + * @param trigger + * The trigger to detect changes + * @param action + * The action to perform + */ + public Reaction(Query query, Trigger trigger, Action action) { + this.query = query; + this.trigger = trigger; + this.action = action; + } + + // + // ACCESSORS + // + + /** + * Returns the query to run. + * + * @return The query to run + */ + public Query query() { + return query; + } + + /** + * Returns the trigger to detect changes. + * + * @return The trigger to detect changes + */ + public Trigger trigger() { + return trigger; + } + + /** + * Returns the action to perform. + * + * @return The action to perform + */ + public Action action() { + return action; + } + + /** + * Returns the current state of the query. + * + * @return The current state of the query + */ + public S currentState() { + return currentState; + } + + /** + * Returns the previous state of the query. + * + * @return The previous state of the query + */ + public S previousState() { + return previousState; + } + +}