当前位置: 首页>>代码示例>>Java>>正文


Java Condition类代码示例

本文整理汇总了Java中org.jooq.Condition的典型用法代码示例。如果您正苦于以下问题:Java Condition类的具体用法?Java Condition怎么用?Java Condition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Condition类属于org.jooq包,在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createNTrueCondition

import org.jooq.Condition; //导入依赖的package包/类
private static Condition createNTrueCondition(final int n) {
    if (n < 1)
        throw new IllegalArgumentException("Cannot have n < 1");
    Condition condition = null;
    for (int i = 0; i < n; i++) {
        if (condition == null)
            condition = DSL.trueCondition();
        else
            condition = condition.and(DSL.trueCondition());
    }
    return condition;
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:13,代码来源:FilteringJooqTest.java

示例2: buildConditions

import org.jooq.Condition; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("goodMapConditionAndResult")
void buildConditions(final Map<String, String> params, final List<FilterValue> filterValues, final Condition expectedCondition) {
    filteringJooqImpl1.getFilterValues().addAll(filterValues);
    final Condition condition = filteringJooqImpl1.buildConditions(params);
    Assertions.assertEquals(expectedCondition, condition);
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:8,代码来源:FilteringJooqTest.java

示例3: update

import org.jooq.Condition; //导入依赖的package包/类
public StorageResult<E> update(E entity, QueryParams queryParams, Map<String, Object> queryMap) {
	logger.info("Update table {} entry by  {}", getProviderTable(), entity);
	try {
		int affectedRows = -1;

		Condition c = null;
		if (queryParams != null) {
			c = addCondition(queryParams, queryMap);
		} else {
			c = DSL.field("id").eq(entity.getId()); // ����Id����
		}
		affectedRows = this.updateRecord(entity, c);

		if (affectedRows == -1) {
			return new StorageResult<E>(StatusCodes.COMMAND_FAILED, false);
		}
		StorageResult<E> updRes = new StorageResult<E>(StatusCodes.NO_CONTENT, true);
		// updRes.setCount((long) affectedRows);
		return updRes;
	} catch (Exception e) {
		logger.error("PUT {} ERROR { }", entity, e);
	}
	return new StorageResult<E>(StatusCodes.INTERNAL_SERVER_ERROR, false);
}
 
开发者ID:SmallBadFish,项目名称:practice,代码行数:25,代码来源:JooqMysqlProvider.java

示例4: buildCondition

import org.jooq.Condition; //导入依赖的package包/类
@NotNull
@Override
public Condition buildCondition(final List<Object> values) {
    if (isConditionSupplier())
        throw new IllegalStateException("Condition supplier is not null");
    // TODO No checking on list size as API should be safe on that but if buildCondition in FilteringJooq is overridden then cannot make sure value count is correct
    if (conditionCreator2 != null) {
        return throwIfConditionIsNull(conditionCreator2.apply(values.get(0), values.get(1)), "Condition cannot be null");
    }

    // TODO could eventually allow Value1 but would require to try a casting to it of the function, if exception then we apply the value without casting otherwise we create the value

    // No checking as API does not allow to specify for one value to use Value1<T1>
    if (values.size() == 1) {
        return throwIfConditionIsNull(conditionCreator.apply(values.get(0)), "Condition cannot be null");
    }

    // More than 2 values will send back a Value object
    final Value value = new ValueImpl(values);
    return throwIfConditionIsNull(conditionCreator.apply(value), "Condition cannot be null");
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:22,代码来源:AbstractFilterValue.java

示例5: delete

import org.jooq.Condition; //导入依赖的package包/类
public StorageResult<E> delete(Object... ids) {
	logger.info("Delete table {} entry by  {}", getProviderTable(), ids);
	try {
		if (ids == null) {
			new StorageResult<E>(StatusCodes.NO_CONTENT, true);
		}
		Condition c = DSL.field("id").in(ids);
		int affectedRows = -1;

		affectedRows = this.deleteRecord(c);

		if (affectedRows == -1) {
			return new StorageResult<E>(StatusCodes.COMMAND_FAILED, false);
		}
		StorageResult<E> updRes = new StorageResult<E>(StatusCodes.NO_CONTENT, true);
		return updRes;
	} catch (Exception e) {
		logger.error("Delte {} ERROR { }", ids, e);
	}
	return new StorageResult<E>(StatusCodes.INTERNAL_SERVER_ERROR, false);
}
 
开发者ID:SmallBadFish,项目名称:practice,代码行数:22,代码来源:JooqMysqlProvider.java

示例6: getConditionProvider

import org.jooq.Condition; //导入依赖的package包/类
@Override
public <T> ConditionProvider<T> getConditionProvider(final Field<T> field) {
  return new MultiParamConditionProvider<T>(field) {

    @SuppressWarnings("unchecked")
    @Override
    public Condition getCondition(Collection<T> values) {
      List<Number> valueList = new ArrayList<Number>((Collection<? extends Number>) values);
      Preconditions.checkArgument(valueList.size() == 2, "Range filters require exactly 2 parameters");

      Collections.sort(valueList, NUMBER_COMPARATOR);
      return field.between((T) valueList.get(0), (T) valueList.get(1));
    }

  };
}
 
开发者ID:HubSpot,项目名称:httpQL,代码行数:17,代码来源:Range.java

示例7: getConditionProvider

import org.jooq.Condition; //导入依赖的package包/类
@Override
public <T> ConditionProvider<T> getConditionProvider(final Field<T> field) {
  return new MultiParamConditionProvider<T>(field) {

    @Override
    public Condition getCondition(Collection<T> values) {
      Iterator<T> iter = values.iterator();
      Condition notLikeCondition = field.notLike((String) iter.next(), '!');
      while (iter.hasNext()) {
        notLikeCondition = notLikeCondition.and(field.notLike((String) iter.next(), '!'));
      }
      return notLikeCondition;
    }

  };
}
 
开发者ID:HubSpot,项目名称:httpQL,代码行数:17,代码来源:NotLike.java

示例8: translate

import org.jooq.Condition; //导入依赖的package包/类
@Override
public Condition translate(PredicatesHolder predicatesHolder) {
    Set<Condition> predicateFilters = predicatesHolder.getPredicates().stream()
            .map(this::extractCondition).collect(Collectors.toSet());
    Set<Condition> childFilters = predicatesHolder.getChildren().stream()
            .map(this::translate).collect(Collectors.toSet());
    predicateFilters.addAll(childFilters);

    if (predicateFilters.size() == 0) return DSL.trueCondition();
    if (predicateFilters.size() == 1) return predicateFilters.iterator().next();

    if (predicatesHolder.getClause().equals(PredicatesHolder.Clause.And)) {
        return predicateFilters.stream().reduce(Condition::and).get();
    } else if (predicatesHolder.getClause().equals(PredicatesHolder.Clause.Or)) {
        return predicateFilters.stream().reduce(Condition::or).get();
    } else throw new IllegalArgumentException("Unexpected clause in predicatesHolder: " + predicatesHolder);
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:18,代码来源:JdbcPredicatesTranslator.java

示例9: handleConnectiveP

import org.jooq.Condition; //导入依赖的package包/类
private Condition handleConnectiveP(String key, ConnectiveP predicate) {
    List<P> predicates = predicate.getPredicates();
    List<Condition> queries = predicates.stream().map(p -> {
        if (p instanceof ConnectiveP) return handleConnectiveP(key, (ConnectiveP) p);
        Object pValue = p.getValue();
        BiPredicate pBiPredicate = p.getBiPredicate();
        return predicateToQuery(key, pValue, pBiPredicate);
    }).collect(Collectors.toList());
    Condition condition = queries.get(0);
    if (predicate instanceof AndP){
        for (int i = 1; i < queries.size(); i++) {
            condition = condition.and(queries.get(i));
        }
    }
    else if (predicate instanceof OrP){
        for (int i = 1; i < queries.size(); i++) {
            condition = condition.or(queries.get(i));
        }
    }
    else throw new IllegalArgumentException("Connective predicate not supported by unipop");
    return condition;
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:23,代码来源:JdbcPredicatesTranslator.java

示例10: predicateToQuery

import org.jooq.Condition; //导入依赖的package包/类
private Condition predicateToQuery(String field, Object value, BiPredicate<?, ?> biPredicate) {
    if (biPredicate instanceof Compare) {
        return getCompareCondition(value, biPredicate, field(field));
    } else if (biPredicate instanceof Contains) {
        Condition x = getContainsCondition(value, biPredicate, field(field));
        if (x != null) return x;
    }
    else if (biPredicate instanceof Text.TextPredicate) {
        return getTextCondition(value, biPredicate, field(field));
    } else if (biPredicate instanceof Date.DatePredicate) {
        try {
            return getDateCondition(value, biPredicate, field(field));
        } catch (ParseException e) {
            throw new IllegalArgumentException("cant convert to date");
        }
    }
    throw new IllegalArgumentException("can't create condition");
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:19,代码来源:JdbcPredicatesTranslator.java

示例11: getCompareCondition

import org.jooq.Condition; //导入依赖的package包/类
private Condition getCompareCondition(Object value, BiPredicate<?, ?> biPredicate, Field<Object> field) {
    String predicateString = biPredicate.toString();
    switch (predicateString) {
        case ("eq"):
            return field.eq(value);
        case ("neq"):
            return field.notEqual(value);
        case ("gt"):
            return field.greaterThan(value);
        case ("gte"):
            return field.greaterOrEqual(value);
        case ("lt"):
            return field.lessThan(value);
        case ("lte"):
            return field.lessOrEqual(value);
        case ("inside"):
            List items = (List) value;
            Object firstItem = items.get(0);
            Object secondItem = items.get(1);
            return field.between(firstItem, secondItem);
        default:
            throw new IllegalArgumentException("predicate not supported in has step: " + biPredicate.toString());
    }
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:25,代码来源:JdbcPredicatesTranslator.java

示例12: getContainsCondition

import org.jooq.Condition; //导入依赖的package包/类
private Condition getContainsCondition(Object value, BiPredicate<?, ?> biPredicate, Field<Object> field) {
    if (biPredicate == Contains.without) {
        if (value == null) {
            return field.isNull();
        } else {
            return field.notIn(value);
        }
    } else if (biPredicate == Contains.within) {
        if (value == null) {
            return field.isNotNull();
        } else {
            return field.in(((Collection) value).toArray());
        }
    }
    return null;
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:17,代码来源:JdbcPredicatesTranslator.java

示例13: getTextCondition

import org.jooq.Condition; //导入依赖的package包/类
private Condition getTextCondition(Object value, BiPredicate<?, ?> biPredicate, Field<Object> field) {
    String predicateString = biPredicate.toString();
    switch (predicateString) {
        case ("LIKE"):
            return field.like(value.toString().replace("*", "%"));
        case ("UNLIKE"):
            return field.notLike(value.toString().replace("*", "%"));
        case ("REGEXP"):
            return field.likeRegex(value.toString());
        case ("UNREGEXP"):
            return field.notLikeRegex(value.toString());
        case ("PREFIX"):
            return field.like(value.toString() + "%");
        case ("UNPREFIX"):
            return field.notLike(value.toString() + "%");
        default:
            throw new IllegalArgumentException("predicate not supported in has step: " + biPredicate.toString());
    }
}
 
开发者ID:unipop-graph,项目名称:unipop,代码行数:20,代码来源:JdbcPredicatesTranslator.java

示例14: addOnlyLastFilter

import org.jooq.Condition; //导入依赖的package包/类
private void addOnlyLastFilter() {
    if (filter.isOnlyLastByStatus() || filter.isOnlyLastByProblem() || filter.isOnlyLastByTeam()) {
        final Submissions s2 = SUBMISSIONS.as("s2");
        Condition condition = SUBMISSIONS.SUBMISSION_ID.lessThan(s2.SUBMISSION_ID);
        if (filter.isOnlyLastByTeam()) {
            condition = condition.and(s2.TEAM_ID.eq(SUBMISSIONS.TEAM_ID));
        }
        if (filter.isOnlyLastByProblem()) {
            condition = condition.and(s2.TASK_ID.eq(SUBMISSIONS.TASK_ID));
        }
        if (filter.isOnlyLastByStatus()) {
            condition = condition.and(s2.RESULT.eq(SUBMISSIONS.RESULT));
        }
        step.leftOuterJoin(s2).on(condition);
        step.where(s2.SUBMISSION_ID.isNull());
    }
}
 
开发者ID:kTT,项目名称:adjule,代码行数:18,代码来源:SubmissionFilterAppender.java

示例15: getSubmissions

import org.jooq.Condition; //导入依赖的package包/类
@Override
public SubmissionListView getSubmissions(final SubmissionListFilter filter,
                                         final Integer page,
                                         final boolean isAdmin) {
    int itemsPerPage = SecurityUtils.getItemsPerPage();

    final SelectJoinStep<Record> submissionSelect = getSubmissionSelect();

    SubmissionFilterAppender.appendOn(filter, submissionSelect);

    if (!isAdmin) {
        final Condition isNotAdmin = USERS.ROLE.ne(Constants.ADMIN_ROLE_VALUE);
        submissionSelect.where(isNotAdmin);

        if (filter.hasStatusFilter()) {
            submissionSelect.where(isFrozenField.isFalse());
        }
    }

    final List<SubmissionDetailView> submissions =
            submissionSelect.orderBy(SUBMISSIONS.CREATED.desc())
                            .limit(itemsPerPage)
                            .offset(page * itemsPerPage)
                            .fetch(submissionDetailRecordMapper);
    return new SubmissionListView(submissions);
}
 
开发者ID:kTT,项目名称:adjule,代码行数:27,代码来源:JooqSubmissionDao.java


注:本文中的org.jooq.Condition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。