private void build(Expression expression, AggregationExpressionVisitor expressionVisitor) {
        if (expression instanceof And) {
            build(((And) expression).getLeftExpression(), expressionVisitor);
            build(((And) expression).getRightExpression(), expressionVisitor);
            expressionVisitor.endVisitAnd();
        } else if (expression instanceof Or) {
            build(((Or) expression).getLeftExpression(), expressionVisitor);
            build(((Or) expression).getRightExpression(), expressionVisitor);
            expressionVisitor.endVisitOr();
        } else if (expression instanceof Not) {
            build(((Not) expression).getExpression(), expressionVisitor);
            expressionVisitor.endVisitNot();
        } else if (expression instanceof Compare) {
            build(((Compare) expression).getLeftExpression(), expressionVisitor);
            build(((Compare) expression).getRightExpression(), expressionVisitor);
            expressionVisitor.endVisitCompare(((Compare) expression).getOperator());
        } else if (expression instanceof Constant) {
            expressionVisitor.addConstantExpression(expression);
        } else if (expression instanceof Variable) {
            expressionVisitor.addVariableExpression(expression);
        } else if (expression instanceof IsNull) {
            IsNull isNull = (IsNull) expression;
            if (isNull.getExpression() != null) {
                build(((IsNull) expression).getExpression(), expressionVisitor);
                expressionVisitor.endVisitIsNull(null);
            }
        } else if (expression instanceof AttributeFunction) {

            Expression[] expressions = ((AttributeFunction) expression).getParameters();
            for (Expression value : expressions) {
                build(value, expressionVisitor);
            }
            expressionVisitor.endVisitAttributeFunction(
                    ((AttributeFunction) expression).getNamespace(),
                    ((AttributeFunction) expression).getName(),
                    expressions.length);

        } else if (expression instanceof Add) {
            build(((Add) expression).getLeftValue(), expressionVisitor);
            build(((Add) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.ADD);
        } else if (expression instanceof Subtract) {
            build(((Subtract) expression).getLeftValue(), expressionVisitor);
            build(((Subtract) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.SUBTRACT);

        } else if (expression instanceof Divide) {
            build(((Divide) expression).getLeftValue(), expressionVisitor);
            build(((Divide) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.DIVIDE);
        } else if (expression instanceof Multiply) {
            build(((Multiply) expression).getLeftValue(), expressionVisitor);
            build(((Multiply) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.MULTIPLY);
        } else if (expression instanceof Mod) {
            build(((Mod) expression).getLeftValue(), expressionVisitor);
            build(((Mod) expression).getRightValue(), expressionVisitor);
            expressionVisitor.endVisitMath(ExpressionVisitor.MathOperator.MOD);
        } else if (expression instanceof In) {
            build(((In) expression).getExpression(), expressionVisitor);
            expressionVisitor.endVisitIn(((In) expression).getSourceId());
        }
    }
Builder to the Aggregation on condition.
modules/siddhi-core/src/main/java/io/siddhi/core/aggregation/AggregationExpressionBuilder.java