ExecutionHistory: Do not add entries for actions that always execute.

This commit is contained in:
asofold 2012-11-09 10:28:57 +01:00
parent eed05511a6
commit c824f54c3d

View File

@ -149,20 +149,22 @@ public class ExecutionHistory {
entries = new HashMap<Action, ExecutionHistoryEntry>(); entries = new HashMap<Action, ExecutionHistoryEntry>();
} }
/** /**
* Returns true, if the action should be executed, because all time criteria have been met. Will add a entry with * Returns true, if the action should be executed, because all time criteria
* the time to a list which will influence further requests, so only use once and remember the result. * have been met. Will add a entry with the time to a list which will
* * influence further requests, so only use once and remember the result.
* @param violationData * If the action is to be executed always, it will not be added to the history.
* the violation data * @param violationData
* @param action * the violation data
* the action * @param action
* @param time * the action
* a time IN SECONDS * @param time
* @return true, if the action is to be executed. * a time IN SECONDS
*/ * @return true, if the action is to be executed.
public boolean executeAction(final ViolationData violationData, final Action action, final long time) { */
public boolean executeAction(final ViolationData violationData, final Action action, final long time)
{
if (action.executesAlways()) return true;
ExecutionHistoryEntry entry = entries.get(action); ExecutionHistoryEntry entry = entries.get(action);
if (entry == null) { if (entry == null) {
entry = new ExecutionHistoryEntry(60); entry = new ExecutionHistoryEntry(60);
@ -190,7 +192,9 @@ public class ExecutionHistory {
* @param time * @param time
* @return * @return
*/ */
public boolean wouldExecute(final ViolationData violationData, final Action action, final long time) { public boolean wouldExecute(final ViolationData violationData, final Action action, final long time)
{
if (action.executesAlways()) return true;
ExecutionHistoryEntry entry = entries.get(action); ExecutionHistoryEntry entry = entries.get(action);
if (entry == null) { if (entry == null) {
return action.delay <= 0; return action.delay <= 0;