Java method parameter and return class object
<p>I am trying to abstract the code in my <a href="https://stackoverflow.com/questions/35210070/converting-jsonobject-to-java-object">previous post</a> into a util class. Here's the util class method:</p>

<pre><code>private static Gson gson = new GsonBuilder().create();

public static Class getResponseObject(String resourceResponse, String jsonObject, Class responseClass) {
    JSONObject jsonResponse = new JSONObject(resourceResponse);
    String jsonResponseToString = jsonResponse.getJSONObject(jsonObject).toString();
    return gson.fromJson(jsonResponseToString, responseClass.getClass());
}
</code></pre>

<p>And this is the call from another class:</p>

<pre><code>UserIdentifier userIdentifier = ServiceClientUtil.getResponseObject(resourceResponse,
                                                                    "userIdentifier",
                                                                    UserIdentifier.class);
</code></pre>

<p>But I'm getting the following error:</p>

<pre><code>Error:(68, 76) java: incompatible types: java.lang.Class cannot be converted to app.identity.UserIdentifier
</code></pre>

<p>How do I pass in a class object and return the same class object?</p>