22
33import org .apache .http .client .fluent .Request ;
44
5- import com .fasterxml .jackson .core .type .TypeReference ;
6- import com .fasterxml .jackson .databind .JsonMappingException ;
7- import com .fasterxml .jackson .databind .ObjectMapper ;
5+ import tools .jackson .core .type .TypeReference ;
6+ import tools .jackson .databind .ObjectMapper ;
87
98import java .io .IOException ;
109import java .util .List ;
@@ -22,29 +21,17 @@ public Product getProduct(String id) throws IOException {
2221 return (Product ) Request .Get (this .url + "/product/" + id )
2322 .addHeader ("Accept" , "application/json" )
2423 .execute ().handleResponse (httpResponse -> {
25- try {
26- ObjectMapper mapper = new ObjectMapper ();
27- Product product = mapper .readValue (httpResponse .getEntity ().getContent (), Product .class );
28-
29- return product ;
30- } catch (JsonMappingException e ) {
31- throw new IOException (e );
32- }
24+ ObjectMapper mapper = new ObjectMapper ();
25+ return mapper .readValue (httpResponse .getEntity ().getContent (), Product .class );
3326 });
3427 }
3528
3629 public List <Product > getProducts () throws IOException {
3730 return (List <Product >) Request .Get (this .url + "/products" )
3831 .addHeader ("Accept" , "application/json" )
3932 .execute ().handleResponse (httpResponse -> {
40- try {
41- ObjectMapper mapper = new ObjectMapper ();
42- List <Product > products = mapper .readValue (httpResponse .getEntity ().getContent (), new TypeReference <List <Product >>(){});
43-
44- return products ;
45- } catch (JsonMappingException e ) {
46- throw new IOException (e );
47- }
33+ ObjectMapper mapper = new ObjectMapper ();
34+ return mapper .readValue (httpResponse .getEntity ().getContent (), new TypeReference <List <Product >>(){});
4835 });
4936 }
5037}
0 commit comments