code: public Predicate connect(List<Predicate> predicates, Connective connective) {
          Predicate[] predicateArray = predicates.toArray(new Predicate[predicates.size()]);
  
          switch (connective) {
              case AND:
                  return cb.and(predicateArray);
              case OR:
                  return cb.or(predicateArray);
              default:
                  throw new UnsupportedOperationException("Unknown connective " + connective);
          }
      }
docs: Joins the given predicates using the criteria builder with the given connective.
  
  @param predicates the predicates to join
  @param connective the logical connective
  @return a new predicate that connects all given predicate