java - Map with Class as keys and values having objects operating on key class instances -


i have problem java generics , i'm not sure if it's possible want get. title says let me give example. have this:

private static map<class<? extends exception>, exceptiontranslator<?>> map; 

which being used in following way:

map.put(someexception.class, new exceptiontranslator<someexception>()); 

but enforce translator of exception type passed key, similar on methods:

<t extends exception> map<class<t>, exceptiontranslator<t>> map; 

this of course not correct code , guess generics-foo not strong enough this. possible in java?

you can't normal map; have own wrapping method enforces type constraint. see related question java generics enforce same type keys , values of map.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -