2 * Reactor - Reaction.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.reactor;
21 * A {@code Reaction} binds together {@link Query}s, {@link Trigger}s, and
22 * {@link Action}s, and it stores the intermediary {@link State}s.
24 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
26 public class Reaction {
28 /** The query to run. */
29 private final Query query;
31 /** The trigger to detect changes. */
32 private final Trigger trigger;
34 /** The action to perform. */
35 private final Action action;
37 /** The interval in which to run queries (in milliseconds). */
38 private long updateInterval;
41 * Creates a new reaction.
46 * The trigger to detect changes
48 * The action to perform
50 public Reaction(Query query, Trigger trigger, Action action) {
52 this.trigger = trigger;
61 * Returns the query to run.
63 * @return The query to run
65 public Query query() {
70 * Returns the trigger to detect changes.
72 * @return The trigger to detect changes
74 public Trigger trigger() {
79 * Returns the action to perform.
81 * @return The action to perform
83 public Action action() {
88 * Returns the update interval of this reaction.
90 * @return The update interval of this reaction (in milliseconds)
92 public long updateInterval() {
93 return updateInterval;
97 * Sets the update interval of this reaction.
99 * @param updateInterval
100 * The update interval of this reaction (in milliseconds)
101 * @return This reaction
103 public Reaction setUpdateInterval(long updateInterval) {
104 this.updateInterval = updateInterval;