This is a contrived example, but simpler to explain than my actual code:
public interface ContainerOwner<T, C extends Container<T>> {
// ...
}
I'd like to avoid the repetition of T
in that type signature because it becomes unwieldy when the parameters themselves have parameters, for example:
ContainerOwner<
Optional<Future<Map<String, Integer>>>,
List<Optional<Future<Map<String, Integer>>>>
> foo;
In this example, I feel like the first parameter could be inferred from the second. Is there a trick to do that?
One way could be to use a more specific sub-interface that will need only one type parameter, something like:
public interface ListOwner<T> extends ContainerOwner<T, List<T>> {
}
Then your code would be:
ListOwner<Optional<Future<Map<String, Integer>>>> foo;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With