Bug description
When calling RecursiveCollectionLineAggregator.aggregate() with an empty collection, the method throws a StringIndexOutOfBoundsException due to an unguarded StringBuilder.delete(...) call.
Expected behavior
It should return an empty string ("") without throwing an exception.
Minimal Complete Reproducible example
In RecursiveCollectionLineAggregatorTests.class:
@Test
void testSetDelegateAndPassEmptyCollection() {
RecursiveCollectionLineAggregator<String> aggregator = new RecursiveCollectionLineAggregator<>();
aggregator.setDelegate(item -> "bar");
assertEquals("", aggregator.aggregate(Collections.emptyList()));
}
Result: java.lang.StringIndexOutOfBoundsException