Search in sources :

Example 1 with ArrayConstructorExpression

use of com.querydsl.core.types.ArrayConstructorExpression in project querydsl by querydsl.

the class DefaultQueryEngine method order.

private void order(QueryMetadata metadata, List<Expression<?>> sources, List<?> list) {
    // create a projection for the order
    List<OrderSpecifier<?>> orderBy = metadata.getOrderBy();
    Expression<Object>[] orderByExpr = new Expression[orderBy.size()];
    boolean[] directions = new boolean[orderBy.size()];
    boolean[] nullsLast = new boolean[orderBy.size()];
    for (int i = 0; i < orderBy.size(); i++) {
        orderByExpr[i] = (Expression) orderBy.get(i).getTarget();
        directions[i] = orderBy.get(i).getOrder() == Order.ASC;
        nullsLast[i] = orderBy.get(i).getNullHandling() == OrderSpecifier.NullHandling.NullsLast;
    }
    Expression<?> expr = new ArrayConstructorExpression<Object>(Object[].class, orderByExpr);
    Evaluator orderEvaluator = evaluatorFactory.create(metadata, sources, expr);
    list.sort(new MultiComparator(orderEvaluator, directions, nullsLast));
}
Also used : ArrayConstructorExpression(com.querydsl.core.types.ArrayConstructorExpression) Expression(com.querydsl.core.types.Expression) ArrayConstructorExpression(com.querydsl.core.types.ArrayConstructorExpression) JoinExpression(com.querydsl.core.JoinExpression) Evaluator(com.querydsl.codegen.utils.Evaluator) OrderSpecifier(com.querydsl.core.types.OrderSpecifier)

Aggregations

Evaluator (com.querydsl.codegen.utils.Evaluator)1 JoinExpression (com.querydsl.core.JoinExpression)1 ArrayConstructorExpression (com.querydsl.core.types.ArrayConstructorExpression)1 Expression (com.querydsl.core.types.Expression)1 OrderSpecifier (com.querydsl.core.types.OrderSpecifier)1