0

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!

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by apines
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.