If I need to return a Class instanced based on a String (e.g., creating logic from JSON), how should that be written?
My initial thought was a switch, but in the Android framework's version of Java, it looks like switch statements don't allow Strings.
Next thought was a HashMap:
private HashMap<String, Class> classMap = new HashMap<String, Class>();
classMap.put("someClass", SomeClass.class)?
// ... etc
String someString = jsonObject.getString("someProperty");
Class classRef = classMap.get(someString);
SomeSuperClass classInstance = new classRef();
This doesn't work. I'd rather not if/else
down a lengthy list of possibilities.