Search in sources :

Example 1 with Case

use of io.requery.query.function.Case in project requery by requery.

the class DefaultOutput method appendFunction.

private void appendFunction(Function function) {
    if (function instanceof Case) {
        appendCaseFunction((Case) function);
    } else {
        Function.Name name = configuration.getMapping().mapFunctionName(function);
        qb.append(name.getName());
        if (function.arguments().length == 0 && name.isConstant()) {
            return;
        }
        qb.openParenthesis();
        int index = 0;
        for (Object arg : function.arguments()) {
            if (index > 0) {
                qb.comma();
            }
            if (arg instanceof Expression) {
                Expression expression = (Expression) arg;
                switch(expression.getExpressionType()) {
                    case ATTRIBUTE:
                        appendColumnForSelect(expression);
                        break;
                    case FUNCTION:
                        Function inner = (Function) arg;
                        appendFunction(inner);
                        break;
                    default:
                        qb.append(expression.getName());
                        break;
                }
            } else if (arg instanceof Class) {
                qb.append("*");
            } else {
                appendConditionValue(function.expressionForArgument(index), arg);
            }
            index++;
        }
        qb.closeParenthesis().space();
    }
}
Also used : Function(io.requery.query.function.Function) Expression(io.requery.query.Expression) NamedExpression(io.requery.query.NamedExpression) RowExpression(io.requery.query.RowExpression) Case(io.requery.query.function.Case)

Aggregations

Expression (io.requery.query.Expression)1 NamedExpression (io.requery.query.NamedExpression)1 RowExpression (io.requery.query.RowExpression)1 Case (io.requery.query.function.Case)1 Function (io.requery.query.function.Function)1