How do I get a class reference from a String in Java?
<p>If I need to return a Class instanced based on a String (e.g., creating logic from JSON), how should that be written?</p>

<p>My initial thought was a switch, but in the Android framework's version of Java, it looks like switch statements don't allow Strings.</p>

<p>Next thought was a HashMap:</p>

<pre><code>private HashMap&lt;String, Class&gt; classMap = new HashMap&lt;String, Class&gt;();
classMap.put("someClass", SomeClass.class)?
// ... etc
String someString = jsonObject.getString("someProperty");
Class classRef = classMap.get(someString);
SomeSuperClass classInstance = new classRef();
</code></pre>

<p>This doesn't work. I'd rather not <code>if/else</code> down a lengthy list of possibilities.</p>
