class OptimizableVisitor extends BooleanExpressionVisitor {

    private final Table table;

    public OptimizableVisitor(Table table) {
        this.table = table;
    }

    @Override
    public Boolean visitRownum(Rownum e) {
        return false;
    }

    @Override
    public Boolean visitExpressionColumn(ExpressionColumn e) {
        return true;
    }

    @Override
    public Boolean visitJavaAggregate(JavaAggregate e) {<FILL_FUNCTION_BODY>}

    @Override
    public Boolean visitAggregate(Aggregate e) {
        return ((BuiltInAggregate) e).isOptimizable(table) && super.visitAggregate(e);
    }
}

        // user defined aggregate functions can not be optimized
        return false;
    
<methods>public non-sealed void <init>() ,public java.lang.Boolean visitAGroupConcat(com.lealone.sql.expression.aggregate.AGroupConcat) ,public java.lang.Boolean visitAggregate(com.lealone.sql.expression.aggregate.Aggregate) ,public java.lang.Boolean visitAlias(com.lealone.sql.expression.Alias) ,public java.lang.Boolean visitCompareLike(com.lealone.sql.expression.condition.CompareLike) ,public java.lang.Boolean visitComparison(com.lealone.sql.expression.condition.Comparison) ,public java.lang.Boolean visitConditionAndOr(com.lealone.sql.expression.condition.ConditionAndOr) ,public java.lang.Boolean visitConditionExists(com.lealone.sql.expression.condition.ConditionExists) ,public java.lang.Boolean visitConditionIn(com.lealone.sql.expression.condition.ConditionIn) ,public java.lang.Boolean visitConditionInConstantSet(com.lealone.sql.expression.condition.ConditionInConstantSet) ,public java.lang.Boolean visitConditionInSelect(com.lealone.sql.expression.condition.ConditionInSelect) ,public java.lang.Boolean visitConditionNot(com.lealone.sql.expression.condition.ConditionNot) ,public java.lang.Boolean visitExpression(com.lealone.sql.expression.Expression) ,public java.lang.Boolean visitExpressionColumn(com.lealone.sql.expression.ExpressionColumn) ,public java.lang.Boolean visitExpressionList(com.lealone.sql.expression.ExpressionList) ,public java.lang.Boolean visitFunction(com.lealone.sql.expression.function.Function) ,public java.lang.Boolean visitJavaAggregate(com.lealone.sql.expression.aggregate.JavaAggregate) ,public java.lang.Boolean visitJavaFunction(com.lealone.sql.expression.function.JavaFunction) ,public java.lang.Boolean visitOperation(com.lealone.sql.expression.Operation) ,public java.lang.Boolean visitParameter(com.lealone.sql.expression.Parameter) ,public java.lang.Boolean visitRownum(com.lealone.sql.expression.Rownum) ,public java.lang.Boolean visitSelect(com.lealone.sql.query.Select) ,public java.lang.Boolean visitSelectUnion(com.lealone.sql.query.SelectUnion) ,public java.lang.Boolean visitSequenceValue(com.lealone.sql.expression.SequenceValue) ,public java.lang.Boolean visitSubQuery(com.lealone.sql.expression.subquery.SubQuery) ,public java.lang.Boolean visitTableFunction(com.lealone.sql.expression.function.TableFunction) ,public java.lang.Boolean visitValueExpression(com.lealone.sql.expression.ValueExpression) ,public java.lang.Boolean visitVariable(com.lealone.sql.expression.Variable) ,public java.lang.Boolean visitWildcard(com.lealone.sql.expression.Wildcard) <variables>