@Override public Object execute(ComplexEvent event) { Object leftObject = leftExpressionExecutor.execute(event); Object rightObject = rightExpressionExecutor.execute(event); if (leftObject == null || rightObject == null) { return null; } return ((Number) leftObject).floatValue() - ((Number) rightObject).floatValue(); }
/** * The initialization method for FunctionExecutor, this method will be called before the other * methods * * @param attributeExpressionExecutors are the executors of each function parameters * @param executionPlanContext the context of the execution plan */ @Override protected void init( ExpressionExecutor[] attributeExpressionExecutors, ExecutionPlanContext executionPlanContext) { for (ExpressionExecutor expressionExecutor : attributeExpressionExecutors) { Attribute.Type attributeType = expressionExecutor.getReturnType(); if (attributeType == Attribute.Type.DOUBLE) { returnType = attributeType; } else if ((attributeType == Attribute.Type.STRING) || (attributeType == Attribute.Type.BOOL)) { throw new ExecutionPlanCreationException( "Plus cannot have parameters with types String or Bool"); } else { returnType = Attribute.Type.LONG; } } }
@Override public ExpressionExecutor cloneExecutor(String key) { return new SubtractExpressionExecutorFloat( leftExpressionExecutor.cloneExecutor(key), rightExpressionExecutor.cloneExecutor(key)); }