@SuppressWarnings("unchecked")
        public Q otherwise(Expression<A> expr) {
            if (expr == null) {
                expr = (Expression) NullExpression.DEFAULT;
            }
            cases.add(0, new CaseElement<A>(null, expr));
            Expression<A> last = null;
            for (CaseElement<A> element : cases) {
                if (last == null) {
                    last = Expressions.operation(type, Ops.CASE_ELSE,
                            element.getTarget());
                } else {
                    last = Expressions.operation(type, Ops.CASE_WHEN,
                            element.getCondition(),
                            element.getTarget(),
                            last);
                }
            }
            return createResult(type, last);
        }
Cascading typesafe Case builder

@author tiwe

@param <A>
@param <Q>
querydsl-core/src/main/java/com/querydsl/core/types/dsl/CaseBuilder.java