I am trying to design a abstract class that will instantiate a Map through a subclass, using an enum type that implements a interface. Contract will be that subclass must instantiate and set variables in it's own constructor.
Here is an example:
Here is the variable from the superclass (T extends Enum & PreferencesIDs)
protected Map<T, String> stringList;
and the abstract method:protected abstract void setPreferences();
While I define the subclass I either can't compile the code or get a bunch of warnings.
Attempt (Either through EnumMaps or HashMaps, using an pIDs enum that implements PreferenceIDs):
stringList = new EnumMap<pIDs, String>(pIDs); stringList.put(pIDs.GENERAL_DATA_FILENAME_EXT, "atv");
When I do this, I get this error:
DataPreferenceManager.java:28: warning: [unchecked] unchecked assignment to variable stringList as member of raw type abstractPreferences.AbstractPreferences
stringList = new EnumMap<pIDs, String>(pIDs.class);
DataPreferenceManager.java:30: warning: [unchecked] unchecked call to put(K,V) as a member of the raw type java.util.Map
Now, is there anyway to do this a more correct way? Any obvious answers? I don't mind reading myself, I just haven't found any direct answers so far.