Create object from Class<?>
<p>Ultimately, I need to be able to do this in my code:</p>

<pre><code>User result = goo.getEntity("users", "id1").getAs(User.class);  
</code></pre>

<p>However, in the above code I need to explicitly cast the result of <code>getEntity</code> to <code>User</code>, what is the approach so that the return type of <code>getAs</code> will be whatever .class is put into the method.</p>

<p>Here is the underlying psuedo-code:</p>

<pre><code>public class EntityType {
    Map json = null;
    public EntityType(Map json){
        this.json = json;
    }
    public Class&lt;?&gt; getAs(Class&lt;?&gt; clazz){
        // create clazz object from json map 
    }
}

public EntityType getEntity(String kind, String id){
    Map json = getFromServer(kind, id);
    EntityType entity = new EntityType(json);
    return entity;
}
</code></pre>
