}
}
responses.clear();
+ if (defaultResponse != null)
+ {
+ defaultResponse.reset();
+ }
firstRunWasCalled = false;
}
if (laction == null)
{
+ if (defaultResponse != null)
+ {
+ defaultResponse.ourTrigger = response;
+ defaultResponse.wasRun = true;
+ defaultResponse.run();
+ }
System.err.println("Doing nothing for " + response);
return;
}
List<Response> responses = new ArrayList<>();
+ RunResponse defaultResponse = null;
+
+ /**
+ * Convenience wrapper for setting default response to a runnable
+ *
+ * @param runnable
+ */
+ public void setDefaultResponse(Runnable runnable)
+ {
+ defaultResponse = new RunResponse(runnable)
+ {
+ @Override
+ public void run()
+ {
+ runnable.run();
+ }
+ };
+ }
+
+ /**
+ * Default responses are called once, with ourTrigger set to the unHandled
+ * response received
+ *
+ * @param runnable
+ */
+ public void setDefaultResponse(RunResponse runnable)
+ {
+ defaultResponse = runnable;
+ }
}