Ignore chains and states default directories.
[rhynodge.git] / src / main / java / net / pterodactylus / reactor / Reaction.java
index e3cfb86..65a637b 100644 (file)
 
 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.
@@ -25,9 +30,15 @@ package net.pterodactylus.reactor;
  */
 public class Reaction {
 
+       /** The name of this reaction. */
+       private final String name;
+
        /** The query to run. */
        private final Query query;
 
+       /** The filters to run. */
+       private final List<Filter> filters = Lists.newArrayList();
+
        /** The trigger to detect changes. */
        private final Trigger trigger;
 
@@ -40,15 +51,37 @@ public class Reaction {
        /**
         * Creates a new reaction.
         *
+        * @param name
+        *            The name of the reaction
+        * @param query
+        *            The query to run
+        * @param trigger
+        *            The trigger to detect changes
+        * @param action
+        *            The action to perform
+        */
+       public Reaction(String name, Query query, Trigger trigger, Action action) {
+               this(name, query, Collections.<Filter> emptyList(), trigger, action);
+       }
+
+       /**
+        * Creates a new reaction.
+        *
+        * @param name
+        *            The name of the 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, Trigger trigger, Action action) {
+       public Reaction(String name, Query query, List<Filter> filters, Trigger trigger, Action action) {
+               this.name = name;
                this.query = query;
+               this.filters.addAll(filters);
                this.trigger = trigger;
                this.action = action;
        }
@@ -58,6 +91,16 @@ public class Reaction {
        //
 
        /**
+        * Returns the name of this reaction. This name is solely used for display
+        * purposes and does not need to be unique.
+        *
+        * @return The name of this reaction
+        */
+       public String name() {
+               return name;
+       }
+
+       /**
         * Returns the query to run.
         *
         * @return The query to run
@@ -67,6 +110,15 @@ public class Reaction {
        }
 
        /**
+        * Returns the filters to run.
+        *
+        * @return The filters to run
+        */
+       public Iterable<Filter> filters() {
+               return filters;
+       }
+
+       /**
         * Returns the trigger to detect changes.
         *
         * @return The trigger to detect changes