CifCollectUtils methods should return the collection
From discussion at !281 (comment 627855):
I'm thinking, can we make the methods also return the list. I know it is an argument and the caller already has it. But now we typically use it as follows:
List<Event> events = list(); collectEvents(spec, events);
If it would also return the list, we could do:
List<Event> events = collectEvents(spec, list());
This would be backward compatible, I think.
To still allow passing any type of collection, it would be something like this then:
public static <T extends Collection<Event>> T collectEvents(ComplexComponent comp, T events) { ... }
I'm wondering, would it be useful to also have:
public static List<Event> collectEvents(ComplexComponent comp) { return collectEvents(spec, list()); }
It would allow using it like:
List<Event> events = collectEvents(spec);
Without having to provide a collection. Although the added benefit is not super great.
Yup, I was thinking that too, but as a separate step.
I like your
T extends Collection<Event>
. It's a nice solution, didn't think of that.
This issue is to address that follow-up to #330 (closed).