String (@NotNull Iterable<?> collection) { if (!collection.iterator().hasNext()) { return "<empty>"; } StringBuilder builder = new StringBuilder(); for (Object o : collection) { if (o instanceof Set) { builder.append(new TreeSet<>((Set<?>)o)); } else { builder.append(o); } builder.append('\n'); if (builder.length() > 1_000_000) { builder.append("...\n"); break; } } return builder.toString(); }