You can't guarantee to java that if you provide a Key
object to your set()
method and there is an another Key
object in array with the same name, that they will have the same type argument. So java can't check type safety of your code at compile time.
So, I think, you should use Raw Types here.