I'm creating a system that has a parameterized class "TypeModule<T>". Now, I have another class that has the following member;

private LinkedHashMap<Class, ArrayList<TypeModule>> m_modules = ...

Here's my dilemma. I need something more like the following;

private LinkedHashMap<Class<?>, ArrayList<TypeModule<?>>> m_modules = ...

The only thing is, I need the '?'s to match types. I can't use a 'T' in place of the '?' because there's going to be different 'T's in the same map. I just want to tell the compiler that the '?'s are going to match. For example, this might be the contents of the map in a specific instance...

String.class -> ArrayList<TypeModule<String>>
Integer.class -> ArrayList<TypeModule<Integer>>
.
.
.

My problem is giving me warnings when I compile the program, although it runs correctly (the code actually ensures that the Class<?> and TypeModule<?> are of the same type), so I can scrape by if there isn't a nice solution to the problem. But, of course, if there is a solution, it would be greatly appreciated!

Thanks in advance!

I remember that I tried to search for a solution but eventually excepted the warnings, and ignored them :) I understand how annoying those warnings can be, but if the code ensures that the types are the same, I don't think you should break your head to much around it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.