I have the following code (java se 6):
import org.javatuples.Pair;
final SortedMap<Pair<AbstractEnum<?>, String>, AdapterObject> myMap =
new TreeMap<Pair<AbstractEnum<?>, String>();
myMap.put(Pair.with(SubTypeEnum.ITEM1, StringUtils.EMPTY), new AdapterObject());
AbstractEnum and SubTypeEnum are just:
public final class SubTypeEnum extends AbstractEnum<SubTypeEnum>
...
public abstract class AbstractEnum<T extends AbstractEnum<T>> implements Comparable<T>, Serializable
Now, the compiler says:
The method put(Pair<AbstractEnum<?>,String>, AdapterObject) in the type Map<Pair<AbstractEnum<?>,String>,AdapterObject> is not applicable for the arguments (Pair<SubTypeEnum,String>, new AdapterObject())
Any ideas how I can fix this?
Change the declaration to:
final SortedMap<Pair<? extends AbstractEnum<?>, String>, AdapterObject> myMap =
new TreeMap<Pair<? extends AbstractEnum<?>,String>, AdapterObject>();