com.querydsl.core.types.ExpressionUtils.allOf()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(360)

本文整理了Java中com.querydsl.core.types.ExpressionUtils.allOf()方法的一些代码示例,展示了ExpressionUtils.allOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExpressionUtils.allOf()方法的具体详情如下:
包路径:com.querydsl.core.types.ExpressionUtils
类名称:ExpressionUtils
方法名:allOf

ExpressionUtils.allOf介绍

[英]Create the intersection of the given arguments
[中]创建给定参数的交集

代码示例

代码示例来源:origin: querydsl/querydsl

private Predicate allOf(Collection<Predicate> predicates) {
  return predicates != null ? ExpressionUtils.allOf(predicates) : null;
}

代码示例来源:origin: spring-projects/spring-data-mongodb

private Predicate allOf(Collection<Predicate> predicates) {
  return predicates != null ? ExpressionUtils.allOf(predicates) : null;
}

代码示例来源:origin: querydsl/querydsl

/**
 * Create a {@code this or all(predicates)} expression
 *
 * <p>Return a union of this and the intersection of the given predicates</p>
 *
 * @param predicates intersection of predicates
 * @return this or all(predicates)
 */
public BooleanExpression orAllOf(Predicate... predicates) {
  return or(ExpressionUtils.allOf(predicates));
}

代码示例来源:origin: querydsl/querydsl

/**
 * Create the union of this and the intersection of the given args
 * {@code (this || (arg1 && arg2 ... && argN))}
 *
 * @param args intersection of predicates
 * @return the current object
 */
public BooleanBuilder orAllOf(Predicate... args) {
  if (args.length > 0) {
    or(ExpressionUtils.allOf(args));
  }
  return this;
}

代码示例来源:origin: querydsl/querydsl

public Q on(Predicate... conditions) {
  return queryMixin.where(ExpressionUtils.predicate(
      MongodbOps.ELEM_MATCH, collection, ExpressionUtils.allOf(conditions)));
}

代码示例来源:origin: spring-projects/spring-data-mongodb

/**
   * Add the given where conditions.
   *
   * @param conditions must not be {@literal null}.
   * @return the target {@link QueryMixin}.
   * @see QueryMixin#where(Predicate)
   */
  public Q on(Predicate... conditions) {

    return queryMixin
        .where(ExpressionUtils.predicate(MongodbOps.ELEM_MATCH, collection, ExpressionUtils.allOf(conditions)));
  }
}

代码示例来源:origin: querydsl/querydsl

@Nullable
protected Predicate createFilter(QueryMetadata metadata) {
  Predicate filter;
  if (!metadata.getJoins().isEmpty()) {
    filter = ExpressionUtils.allOf(metadata.getWhere(), createJoinFilter(metadata));
  } else {
    filter = metadata.getWhere();
  }
  return filter;
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@Nullable
protected Predicate createFilter(QueryMetadata metadata) {
  Predicate filter;
  if (!metadata.getJoins().isEmpty()) {
    filter = ExpressionUtils.allOf(metadata.getWhere(), createJoinFilter(metadata));
  } else {
    filter = metadata.getWhere();
  }
  return filter;
}

代码示例来源:origin: spring-projects/spring-data-mongodb

protected Mono<Predicate> createFilter(QueryMetadata metadata) {
  if (!metadata.getJoins().isEmpty()) {
    return createJoinFilter(metadata).map(it -> ExpressionUtils.allOf(metadata.getWhere(), it))
        .switchIfEmpty(Mono.justOrEmpty(metadata.getWhere()));
  }
  return Mono.justOrEmpty(metadata.getWhere());
}

代码示例来源:origin: querydsl/querydsl

@SuppressWarnings("unchecked")
@Nullable
protected Predicate createJoinFilter(QueryMetadata metadata) {
  Multimap<Expression<?>, Predicate> predicates = HashMultimap.create();
  List<JoinExpression> joins = metadata.getJoins();
  for (int i = joins.size() - 1; i >= 0; i--) {
    JoinExpression join = joins.get(i);
    Path<?> source = (Path) ((Operation<?>) join.getTarget()).getArg(0);
    Path<?> target = (Path) ((Operation<?>) join.getTarget()).getArg(1);
    Collection<Predicate> extraFilters = predicates.get(target.getRoot());
    Predicate filter = ExpressionUtils.allOf(join.getCondition(), allOf(extraFilters));
    List<? extends Object> ids = getIds(target.getType(), filter);
    if (ids.isEmpty()) {
      throw new NoResults();
    }
    Path<?> path = ExpressionUtils.path(String.class, source, "$id");
    predicates.put(source.getRoot(), ExpressionUtils.in((Path<Object>) path, ids));
  }
  Path<?> source = (Path) ((Operation) joins.get(0).getTarget()).getArg(0);
  return allOf(predicates.get(source.getRoot()));
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@SuppressWarnings("unchecked")
@Nullable
protected Predicate createJoinFilter(QueryMetadata metadata) {
  LinkedMultiValueMap<Expression<?>, Predicate> predicates = new LinkedMultiValueMap<>();
  List<JoinExpression> joins = metadata.getJoins();
  for (int i = joins.size() - 1; i >= 0; i--) {
    JoinExpression join = joins.get(i);
    Path<?> source = (Path) ((Operation<?>) join.getTarget()).getArg(0);
    Path<?> target = (Path) ((Operation<?>) join.getTarget()).getArg(1);
    Collection<Predicate> extraFilters = predicates.get(target.getRoot());
    Predicate filter = ExpressionUtils.allOf(join.getCondition(), allOf(extraFilters));
    List<? extends Object> ids = getIds(target.getType(), filter);
    if (ids.isEmpty()) {
      return ExpressionUtils.predicate(QuerydslMongoOps.NO_MATCH, source);
    }
    Path<?> path = ExpressionUtils.path(String.class, source, "$id");
    predicates.add(source.getRoot(), ExpressionUtils.in((Path<Object>) path, ids));
  }
  Path<?> source = (Path) ((Operation) joins.get(0).getTarget()).getArg(0);
  return allOf(predicates.get(source.getRoot()));
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

private Predicate allOf(Collection<Predicate> predicates) {
  return predicates != null ? ExpressionUtils.allOf(predicates) : null;
}

代码示例来源:origin: spring-projects/spring-data-mongodb

Collection<Mono<Predicate>> extraFilters = predicates.get(target.getRoot());
Mono<Predicate> filter = allOf(extraFilters).map(it -> ExpressionUtils.allOf(join.getCondition(), it))
    .switchIfEmpty(Mono.justOrEmpty(join.getCondition()));

代码示例来源:origin: org.springframework.data/spring-data-mongodb

/**
   * Add the given where conditions.
   *
   * @param conditions must not be {@literal null}.
   * @return the target {@link QueryMixin}.
   * @see QueryMixin#where(Predicate)
   */
  public Q on(Predicate... conditions) {

    return queryMixin
        .where(ExpressionUtils.predicate(MongodbOps.ELEM_MATCH, collection, ExpressionUtils.allOf(conditions)));
  }
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@Nullable
protected Predicate createFilter(QueryMetadata metadata) {
  Predicate filter;
  if (!metadata.getJoins().isEmpty()) {
    filter = ExpressionUtils.allOf(metadata.getWhere(), createJoinFilter(metadata));
  } else {
    filter = metadata.getWhere();
  }
  return filter;
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

@SuppressWarnings("unchecked")
@Nullable
protected Predicate createJoinFilter(QueryMetadata metadata) {
  LinkedMultiValueMap<Expression<?>, Predicate> predicates = new LinkedMultiValueMap<>();
  List<JoinExpression> joins = metadata.getJoins();
  for (int i = joins.size() - 1; i >= 0; i--) {
    JoinExpression join = joins.get(i);
    Path<?> source = (Path) ((Operation<?>) join.getTarget()).getArg(0);
    Path<?> target = (Path) ((Operation<?>) join.getTarget()).getArg(1);
    Collection<Predicate> extraFilters = predicates.get(target.getRoot());
    Predicate filter = ExpressionUtils.allOf(join.getCondition(), allOf(extraFilters));
    List<? extends Object> ids = getIds(target.getType(), filter);
    if (ids.isEmpty()) {
      return ExpressionUtils.predicate(QuerydslMongoOps.NO_MATCH, source);
    }
    Path<?> path = ExpressionUtils.path(String.class, source, "$id");
    predicates.add(source.getRoot(), ExpressionUtils.in((Path<Object>) path, ids));
  }
  Path<?> source = (Path) ((Operation) joins.get(0).getTarget()).getArg(0);
  return allOf(predicates.get(source.getRoot()));
}

代码示例来源:origin: org.huiche/huiche-data

/**
 * 用and组合多个条件
 *
 * @param predicate 多个条件
 * @return 最终条件
 */
@Nullable
default Predicate predicates(@Nonnull Predicate... predicate) {
  return ExpressionUtils.allOf(predicate);
}

代码示例来源:origin: org.huiche/huiche-data

/**
 * 用and组合多个条件,等同predicates
 *
 * @param predicate 多个条件
 * @return 最终条件
 */
@Nullable
default Predicate and(@Nonnull Predicate... predicate) {
  return ExpressionUtils.allOf(predicate);
}

代码示例来源:origin: org.huiche/huiche-dao

/**
 * 删除
 *
 * @param id        ID
 * @param predicate 条件
 * @return 变更条数
 */
default long delete(long id, @Nullable Predicate... predicate) {
  return delete(pk().eq(id), null == predicate ? null : ExpressionUtils.allOf(predicate));
}

代码示例来源:origin: org.huiche/huiche-dao

/**
 * 是否存在
 *
 * @param id        主键ID
 * @param predicate 条件
 * @return 是否存在
 */
default boolean exists(long id, @Nullable Predicate... predicate) {
  return exists(pk().eq(id), null == predicate ? null : ExpressionUtils.allOf(predicate));
}

相关文章