publicclassGsonRequest<T>extendsRequest<T>{privatefinalGsongson=newGson();privatefinalClass<T>clazz;privatefinalMap<String,String>headers;privatefinalListener<T>listener;/** * Make a GET request and return a parsed object from JSON. * * @param url URL of the request to make * @param clazz Relevant class object, for Gson's reflection * @param headers Map of request headers */publicGsonRequest(Stringurl,Class<T>clazz,Map<String,String>headers,Listener<T>listener,ErrorListenererrorListener){super(Method.GET,url,errorListener);this.clazz=clazz;this.headers=headers;this.listener=listener;}@OverridepublicMap<String,String>getHeaders()throwsAuthFailureError{returnheaders!=null?headers:super.getHeaders();}@OverrideprotectedvoiddeliverResponse(Tresponse){listener.onResponse(response);}@OverrideprotectedResponse<T>parseNetworkResponse(NetworkResponseresponse){try{Stringjson=newString(response.data,HttpHeaderParser.parseCharset(response.headers));returnResponse.success(gson.fromJson(json,clazz),HttpHeaderParser.parseCacheHeaders(response));}catch(UnsupportedEncodingExceptione){returnResponse.error(newParseError(e));}catch(JsonSyntaxExceptione){returnResponse.error(newParseError(e));}}}