I have a method look like this.
public void some(..., Collection<? super Some> collection) {
// WOOT, PECS!!!
final Stream<Some> stream = getStream();
stream.collect(toCollection(() -> collection));
}
And how can I make this method returns given collection instance type-safely?
I tried this.
public <T extends Collection<? super Some>> T some(..., T collection) {
final Stream<Some> stream = getStream();
stream.collect(toCollection(() -> collection)); // error.
return collection; // this is what I want to do
}