From bf9e2f0f046ab9b724ca25268668a166afb4c582 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 2 Jan 2013 13:39:06 +0100 Subject: [PATCH] Add filters to reaction. --- .../java/net/pterodactylus/reactor/Reaction.java | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/main/java/net/pterodactylus/reactor/Reaction.java b/src/main/java/net/pterodactylus/reactor/Reaction.java index e3cfb86..59fad8f 100644 --- a/src/main/java/net/pterodactylus/reactor/Reaction.java +++ b/src/main/java/net/pterodactylus/reactor/Reaction.java @@ -17,6 +17,11 @@ package net.pterodactylus.reactor; +import java.util.Collections; +import java.util.List; + +import com.google.common.collect.Lists; + /** * A {@code Reaction} binds together {@link Query}s, {@link Trigger}s, and * {@link Action}s, and it stores the intermediary {@link State}s. @@ -28,6 +33,9 @@ public class Reaction { /** The query to run. */ private final Query query; + /** The filters to run. */ + private final List filters = Lists.newArrayList(); + /** The trigger to detect changes. */ private final Trigger trigger; @@ -48,7 +56,24 @@ public class Reaction { * The action to perform */ public Reaction(Query query, Trigger trigger, Action action) { + this(query, Collections. emptyList(), trigger, action); + } + + /** + * Creates a new reaction. + * + * @param query + * The query to run + * @param filters + * The filters to run + * @param trigger + * The trigger to detect changes + * @param action + * The action to perform + */ + public Reaction(Query query, List filters, Trigger trigger, Action action) { this.query = query; + this.filters.addAll(filters); this.trigger = trigger; this.action = action; } @@ -67,6 +92,15 @@ public class Reaction { } /** + * Returns the filters to run. + * + * @return The filters to run + */ + public Iterable filters() { + return filters; + } + + /** * Returns the trigger to detect changes. * * @return The trigger to detect changes -- 2.7.4