public static <T extends Comparable<?>> ComparableExpression<T> asComparable(Expression<T> expr) {
        Expression<T> underlyingMixin = ExpressionUtils.extract(expr);
        if (underlyingMixin instanceof PathImpl) {
            return new ComparablePath<T>((PathImpl<T>) underlyingMixin);
        } else if (underlyingMixin instanceof OperationImpl) {
            return new ComparableOperation<T>((OperationImpl<T>) underlyingMixin);
        } else if (underlyingMixin instanceof TemplateExpressionImpl) {
            return new ComparableTemplate<T>((TemplateExpressionImpl<T>) underlyingMixin);
        } else {
            return new ComparableExpression<T>(underlyingMixin) {

                private static final long serialVersionUID = 389920618099394430L;

                @Override
                public <R, C> R accept(Visitor<R, C> v, C context) {
                    return this.mixin.accept(v, context);
                }

                @Override
                public boolean equals(Object o) {
                    if (o == this) {
                        return true;
                    } else if (o instanceof ComparableExpression) {
                        ComparableExpression other = (ComparableExpression) o;
                        return (other.mixin.equals(this.mixin));
                    } else {
                        return false;
                    }
                }

            };
        }

    }
Create a new ComparableExpression

@param expr Expression of type Comparable
@return new ComparableExpression
querydsl-core/src/main/java/com/querydsl/core/types/dsl/Expressions.java