Run filters after query to convert the state.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 2 Jan 2013 12:39:17 +0000 (13:39 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 2 Jan 2013 12:39:17 +0000 (13:39 +0100)
src/main/java/net/pterodactylus/reactor/engine/Engine.java

index 123781f..41aedb7 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.concurrent.TimeUnit;
 
+import net.pterodactylus.reactor.Filter;
 import net.pterodactylus.reactor.Query;
 import net.pterodactylus.reactor.Reaction;
 import net.pterodactylus.reactor.Trigger;
@@ -129,6 +130,13 @@ public class Engine extends AbstractExecutionThreadService {
                                };
                        }
                        logger.debug(String.format("State is %s.", state));
+
+                       /* convert states. */
+                       for (Filter filter : nextReaction.filters()) {
+                               net.pterodactylus.reactor.State newState = filter.filter(state);
+                               logger.debug(String.format("Old state is %s, new state is %s.", state, newState));
+                               state = newState;
+                       }
                        reactionExecution.addState(state);
 
                        /* only run trigger if we have collected two states. */