I am just learning how to use wildcards and bounded type parameters. I want to use (I think) bounded wildcards in a method that is passed a HashMap. I've seen examples of bounded type parameters and bounded wildcards but I haven't found anything that shows me how to pass a HashMap into a method where the HashMap can contain different value objects.
Map<Integer, Company>
Map<Integer, Employee>
Map<Integer, Location>
This is what I have as an example for the first Map listed above:
public Map<Integer, Company> readXML(Map<Integer, Company> companies) {
I want to use something like the following to enable this method to deal with any one of my Maps listed above.
public Map<Integer, ?> readXML(Map<Integer, ?> values) {
Can somebody show me an example for how I can use wildcards for the Map values in this method?
1) Do I need to create a Map class that extends the value objects (Company, Employee, Location)?
2) Or is there a better way to accomplish this? In other words, am I doing it wrong?
Thank you for your advice.