Hi,
I have an issue with Generics and types, I hope I may find some help here.
I have the following map :
protected static HashMap<String, Action<EndpointClient>> dictionary =
new HashMap<String, Action<EndpointClient>>();
In this map I want to put :
protected static final Action<EndpointClient> ACTION_SEND_PRIVATE = new ActionSendPrivateMessage();
protected static final Action<EndpointClientAdmin> ACTION_SEND_TO_ALL = new ActionSendMessageToAll();
dictionary.put(Constants.MSG_SEND_PRIVATE, ACTION_SEND_PRIVATE);
dictionary.put(Constants.MSG_SEND_TO_ALL, ACTION_SEND_TO_ALL);
I have a problem in adding the ACTION_SEND_TO_ALL variable in the map, it says :
The method put(String, Action<EndpointClient>) in the type+
HashMap<String,Action<EndpointClient>> is not applicable for the arguments (String, Action<EndpointClientAdmin>)+
However EndpointClientAdmin extends EndpointClient ...
In java it's possible to to do something like:
List myList = new ArrayList();
and thus reduce the visibility of the class ArrayList.
Why isn't it possible with Generics like this case above ?
Thank you very much ...