全部
我有以下定义:
JsonResponse.class如下:
public abstract class JsonResponse<T> extends AbstractResponse {
private T jsonObject;
public JsonResponse(HttpResponse httpResponse, Class<T> classT) {
super(httpResponse);
jsonObject = new Gson().fromJson(
ResponseUtils.getStringContent(getHttpResponse()), classT);
}
public T getJsonObject() {
return jsonObject;
}
}
但在课堂下面我想新建并返回:
return new JsonResponse<T>(response, classT);
但我无法编译它并出错,请你看看它。谢谢你 。
public class JsonResponseHandler<T> implements ResponseHandler<JsonResponse<T>> {
private Class<T> classT;
public JsonResponseHandler(Class<T> classT) {
this.classT = classT;
}
@Override
public JsonResponse<T> handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {
return new JsonResponse<T>(response, classT) ; //compile always error
}
}