-
Notifications
You must be signed in to change notification settings - Fork 8
Description
The until trigger is not implemented correctly yet. Instead of an ArdenTime, it should contain a boolean expression:
EVERY 5 SECONDS FOR 1 MINUTE STARTING TIME OF an_event UNTIL x > y;
The evaluation of this boolean expression (x > y) must happen at runtime.
The bytecode for the expressions must reside somewhere. Putting it into an inner or anonymous class (like Callable) would require creating not one but multiple .class files when compiling an MLM. The code for every UNTIL expression could reside in it's own method in the generate class:
public boolean untilExpr0()public boolean untilExpr1()- …
These methods are then passed via reflection to the UntilTrigger, which can evoke them.
Instead of reflection Java 8 supports functional programming without reflection via functional interfaces:
@FunctionalInterface
public interface UntilExpression {
public boolean evaluate();
}
public class MyMLM {
public boolean untilExpr0() {
return …;
}
public Trigger[] getTriggers() {
UntilExpression expr = this::untilExpr0;
return new Trigger[]{
new UntilTrigger(expr);
};
}
}Java 8 also supports lambdas, short inline functions, that don't require a new class. Generating bytecode for lambdas seems like a lot of work though.