1 package org.oxerr.okcoin.rest.dto; 2 3 import java.io.IOException; 4 import java.net.URL; 5 6 import com.fasterxml.jackson.core.type.TypeReference; 7 import com.fasterxml.jackson.databind.ObjectMapper; 8 9 public class UnmarshalTest { 10 11 private final ObjectMapper mapper; 12 13 public UnmarshalTest() { 14 mapper = new ObjectMapper(); 15 } 16 17 protected <T> T readValue(String resource, Class<T> valueType) 18 throws IOException { 19 URL url = getClass().getResource(resource); 20 return mapper.readValue(url, valueType); 21 } 22 23 protected <T> T readValue(String resource, TypeReference<T> valueTypeRef) 24 throws IOException { 25 URL url = getClass().getResource(resource); 26 return mapper.readValue(url, valueTypeRef); 27 } 28 29 }