/** * Check whether a comparison is valid i.e. the arguments are comparable types and the * the operator is permitted for those types * @param arg1 the first argument * @param op how to compare the arguments * @param arg2 the second argument * @return whether the comparison is valid */ public static boolean validComparison(Class<?> arg1, ConstraintOp op, Class<?> arg2) { if (arg2 == null) { return op == ConstraintOp.IS_NULL || op == ConstraintOp.IS_NOT_NULL; } if (comparable(arg1, arg2)) { return validOps(arg1).contains(op); } return false; }
/** * Check whether a comparison is valid i.e. the arguments are comparable types and the * the operator is permitted for those types * @param arg1 the first argument * @param op how to compare the arguments * @param arg2 the second argument * @return whether the comparison is valid */ public static boolean validComparison(Class<?> arg1, ConstraintOp op, Class<?> arg2) { if (arg2 == null) { return op == ConstraintOp.IS_NULL || op == ConstraintOp.IS_NOT_NULL; } if (comparable(arg1, arg2)) { return validOps(arg1).contains(op); } return false; }