Consider having a generic type:
public interface <T> Assigner {
<S> S assign(T type);
}
Now, let's say I want to have different types of assigners that could assign an object of any type T
to a group of any type S
. Example:
interface PlayerAssigner extends Assigner<Player> {
<S> S assign(Player player);
}
interface ManagerAssigner extends Assigner<Manager> {
<S> S assign(Manager manager);
}
...
I would also like to introduce a group-type-based assigner, but this is where I got stuck. I tried:
interface CityBasedAssigner<T> extends Assigner<T> {
City assign(T type);
}
, but this won't work, it says that both methods have the same erasure. I don't know whether it should be an abstract class or something different, or whether the whole concept could be simplified. What I want is to be able to instantiate different types of assigners from the combination of two type parameters, e.g. CityBasedPlayerAssigner, CountryBasedPlayerAssigner, CountryBasedManagerAssigner, etc., and this would have been the next step: combining the two extended interfaces and create many implementations based on these two.
What am I missing here?