I'm trying to do this:
public interface Foo<T> {
Stream<String> getAllKeys();
T getItemByKey(String key);
}
However, it appears that type erasure gets rid of the String, so when I call getAllKeys
I get back a raw Stream
.
I thought this would work because these aren't methods with the same signature, and the Stream type param is essentially bound which apparently should therefore get compiled to that type.
Is there any way to make this work, or is it a shortcoming of Java generics? Even casting the Stream or its elements doesn't seem to be working well.