I have a situation where I have a User that is a certain profession, so I have something like:
public abstract class Job
{
private static String name;
public static String getJobName() { return name; }
}
and
public class Baker extends Job
{
// I realize this is probably wrong, but not the main point
Baker() { name = "Baker"; }
}
Then i wanted to store the User->Profession in a map like
Map<User, Class<? extends Job>> uJobs = HashMap<User, Class<? extends Job>>();
uJobs.put(user, Baker.class); // This seems to work
String jobName = uJobs.get(user).getJobName(); // This not so much, and the IDE (eclipse) just somes 'class' specific stuff, not Job specific stuff.
Any advice is appreciated. The core goal here is to map 1 Object to a Class that I can just call static methods from without needing an instance for every Object.