I want to create a typesafe collection which can store multiple collections of the same type but with typesafe parameters. The standart way:
Map<Key<?>, Object> container = new HashMap<();
The key contains the type of the object and the get method casts to the correct type (standart typesafe hetereogeneous container pattern). But i need something like this:
container.put(Key, new HashMap<Long, String>);
The type itself would be safe (Map.class) but i don't know how to ensure that key and value of the map are of the type long and string. How can i do that with java?
Aucun commentaire:
Enregistrer un commentaire