Пример #1
0
 protected static org.jooq.Condition toCondition(TableField<?, Object> field, Condition value) {
   Condition condition = value;
   switch (condition.getConditionType()) {
     case EQ:
       return field.eq(condition.getValue());
     case GT:
       return field.gt(condition.getValue());
     case GTE:
       return field.ge(condition.getValue());
     case IN:
       List<Object> values = condition.getValues();
       if (values.size() == 1) {
         return field.eq(values.get(0));
       } else {
         return field.in(condition.getValues());
       }
     case NOTIN:
       List<Object> vals = condition.getValues();
       if (vals.size() == 1) {
         return field.ne(vals.get(0));
       } else {
         return field.notIn(condition.getValues());
       }
     case LIKE:
       return field.like(condition.getValue().toString());
     case LT:
       return field.lt(condition.getValue());
     case LTE:
       return field.le(condition.getValue());
     case NE:
       return field.ne(condition.getValue());
     case NOTLIKE:
       return field.notLike(condition.getValue().toString());
     case NOTNULL:
       return field.isNotNull();
     case NULL:
       return field.isNull();
     case PREFIX:
       return field.like(condition.getValue() + "%");
     case OR:
       return toCondition(field, condition.getLeft()).or(toCondition(field, condition.getRight()));
     default:
       throw new IllegalArgumentException(
           "Invalid condition type [" + condition.getConditionType() + "]");
   }
 }