static <T> void accept(@NotNull DomainObjectCollection<T> collection, @NotNull GradleCollectionVisitor<? super T> visitor) {
    AtomicBoolean isCollected = new AtomicBoolean(false);
    collection.all(element -> {
      if (isCollected.get()) {
        visitor.visitAfterAccept(element);
      }
      try {
        visitor.visit(element);
      }
      catch (Exception exception) {
        visitor.onFailure(element, exception);
      }
    });
    isCollected.set(true);
  }
static <T> void accept(@NotNull DomainObjectCollection<T> collection, @NotNull GradleCollectionVisitor<? super T> visitor)