@SuppressWarnings("unchecked")
        private <A extends Number & Comparable<?>> Cases<A, NumberExpression<A>> thenNumber(Expression<A> expr) {
            return new Cases<A, NumberExpression<A>>(expr.getType()) {
                @Override
                protected NumberExpression<A> createResult(Class<? extends A> type, Expression<A> last) {
                    return Expressions.numberOperation(type, Ops.CASE, last);
                }

            }.addCase(when, expr);
        }
Initial state of Case construction

@author tiwe
querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseBuilder.java