public static FilePredicate create(Collection<FilePredicate> predicates) {
    if (predicates.isEmpty()) {
      return TruePredicate.TRUE;
    }
    AndPredicate result = new AndPredicate();
    for (FilePredicate filePredicate : predicates) {
      if (filePredicate == TruePredicate.TRUE) {
        continue;
      } else if (filePredicate == FalsePredicate.FALSE) {
        return FalsePredicate.FALSE;
      } else if (filePredicate instanceof AndPredicate andPredicate) {
        result.predicates.addAll(andPredicate.predicates);
      } else {
        result.predicates.add(OptimizedFilePredicateAdapter.create(filePredicate));
      }
    }
    Collections.sort(result.predicates);
    return result;
  }
@Test
  public void simplifyAndExpressionsWhenEmpty() {
    FilePredicate andPredicate = AndPredicate.create(Arrays.asList());
    assertThat(andPredicate).isEqualTo(TruePredicate.TRUE);
  }