public class BranchFlowProcessor extends LineEndProcessor {
@Override
public void emitLineEnd(Context context) {
ModelFactory f = context.getModelFactory();
Expression input = context.getInput();
Expression impl = context.createImplementation();
OperatorDescription desc = context.getOperatorDescription();
Method method = desc.getDeclaration().toMethod();
assert method != null : desc.getDeclaration();
Class<?> enumType = method.getReturnType();
List<Expression> arguments = Lists.create();
arguments.add(input);
for (OperatorDescription.Parameter param : desc.getParameters()) {
arguments.add(Models.toLiteral(f, param.getValue()));
}
Expression result = context.createLocalVariable(
enumType,
new ExpressionBuilder(f, impl)
.method(desc.getDeclaration().getName(), arguments)
.toExpression());
List<Tuple2<Enum<?>, FlowElementPortDescription>> constants =