public static Constant toConstant(Expression expression) {
    return maybeConstant(expression)
            .orElseThrow(() -> ERROR_FN.apply(expression, Constant.class));
  }
Assumes current expression is a {@link Constant}. Throws exception when it is not.
criteria/common/src/org/immutables/criteria/expression/Visitors.java