List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.playonlinux.engines.wine.WineversionsSourceWebserviceDefaultImplementation.java
@Override protected TypeReference<List<WineVersionDistributionWebDTO>> defineTypeReference() { return new TypeReference<List<WineVersionDistributionWebDTO>>() { };/* www .jav a 2s.c o m*/ }
From source file:com.microsoft.visualstudio.services.account.AccountHttpClient.java
public List<Account> getAccounts(final UUID memberId) { final UUID locationId = UUID.fromString("229A6A53-B428-4FFB-A835-E8F36B5B4B1E"); final ApiResourceVersion apiVersion = new ApiResourceVersion("3.0-preview.1"); //$NON-NLS-1$ final Map<String, String> queryParams = new HashMap<String, String>(); queryParams.put("memberId", memberId.toString()); final Invocation httpRequest = super.createRequest(HttpMethod.GET, locationId, null, apiVersion, queryParams, APPLICATION_JSON_TYPE); return super.sendRequest(httpRequest, new TypeReference<List<Account>>() { });/*from w w w. j a v a 2 s. co m*/ }
From source file:uk.co.sdev.async.http.ning.Parallel2SequentialCompletableFutureClientTest.java
@Override protected CompletableFuture<Optional<Numerator>> getNumerator() throws IOException { return completableFutureClient .get("http://localhost:9101/numerator", new TypeReference<Optional<Numerator>>() { }).handle(withFallback(Optional.<Numerator>empty())); }
From source file:codes.thischwa.c5c.requestcycle.response.mode.JacksonTest.java
@Test public void testReadValue() throws JsonParseException, JsonMappingException, IOException { String str = "{'test name': 'test', 'value': 'val'}".replace("'", "\""); Map<String, Object> objs = new HashMap<>(); ObjectMapper mapper = new ObjectMapper(); objs = mapper.readValue(str, new TypeReference<Map<String, Object>>() { });/*from ww w .java 2 s.c om*/ assertEquals("test", objs.get("test name")); }
From source file:io.sprucehill.mandrill.service.TemplateService.java
@Override public String render(RenderTemplatePayload payload) throws RenderTemplateError, IOException { try {//from w ww . ja va 2s . c o m RenderTemplateResponse renderTemplateResponse = send(payload, new TypeReference<RenderTemplateResponse>() { }, RenderTemplateError.class); return renderTemplateResponse.getHtml(); } catch (MessageError e) { logger.warn("Got RenderTemplateError with code {}, name {} and message {} when rendering template!", new Object[] { e.getCode().toString(), e.getName(), e.getMessage() }); throw e; } catch (IOException e) { logger.error("Got IOException while rendering template!"); throw e; } }
From source file:spring.travel.site.services.UserService.java
public CompletableFuture<Optional<User>> user(Optional<String> id) { return id.<CompletableFuture<Optional<User>>>map( i -> client.get(url(i), new TypeReference<Optional<User>>() { }).handle(withFallback(Optional.<User>empty()))).orElse(none()); }
From source file:org.opendatakit.utilities.LocalizationUtils.java
private static synchronized void loadTranslations(String appName, String tableId) throws IOException { if (savedAppName != null && !savedAppName.equals(appName)) { clearTranslations();/*from ww w . j a v a 2 s . co m*/ } savedAppName = appName; TypeReference<HashMap<String, Object>> ref = new TypeReference<HashMap<String, Object>>() { }; if (commonDefinitions == null) { File commonFile = new File(ODKFileUtils.getCommonDefinitionsFile(appName)); if (commonFile.exists() && commonFile.isFile()) { InputStream stream = null; BufferedReader reader = null; String value; try { stream = new FileInputStream(commonFile); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); } else { reader = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8)); } int ch = reader.read(); while (ch != -1 && ch != '{') { ch = reader.read(); } StringBuilder b = new StringBuilder(); b.append((char) ch); ch = reader.read(); while (ch != -1) { b.append((char) ch); ch = reader.read(); } reader.close(); stream.close(); value = b.toString().trim(); if (value.endsWith(";")) { value = value.substring(0, value.length() - 1).trim(); } } finally { if (reader != null) { reader.close(); } else if (stream != null) { stream.close(); } } try { commonDefinitions = ODKFileUtils.mapper.readValue(value, ref); } catch (IOException e) { WebLogger.getLogger(appName).printStackTrace(e); throw new IllegalStateException("Unable to read commonDefinitions.js file"); } } } if (tableId != null) { File tableFile = new File(ODKFileUtils.getTableSpecificDefinitionsFile(appName, tableId)); if (!tableFile.exists()) { tableSpecificDefinitionsMap.remove(tableId); } else { // assume it is current if it exists if (tableSpecificDefinitionsMap.containsKey(tableId)) { return; } InputStream stream = null; BufferedReader reader = null; try { stream = new FileInputStream(tableFile); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); } else { reader = new BufferedReader(new InputStreamReader(stream, Charsets.UTF_8)); } reader.mark(1); int ch = reader.read(); while (ch != -1 && ch != '{') { reader.mark(1); ch = reader.read(); } reader.reset(); Map<String, Object> tableSpecificTranslations = ODKFileUtils.mapper.readValue(reader, ref); if (tableSpecificTranslations != null) { tableSpecificDefinitionsMap.put(tableId, tableSpecificTranslations); } } finally { if (reader != null) { reader.close(); } else if (stream != null) { stream.close(); } } } } }
From source file:com.nesscomputing.jackson.datatype.CommonsLang3SerializerTest.java
@Test public void testPair() throws IOException { Pair<String, Boolean> pair = Pair.of("foo", true); Pair<String, Boolean> newPair = mapper.readValue(mapper.writeValueAsBytes(pair), new TypeReference<Pair<String, Boolean>>() { });//from w ww .j a va2s . c o m assertEquals(pair, newPair); }
From source file:uk.co.sdev.async.http.ning.Parallel2CompletableFutureClientTest.java
@Override protected CompletableFuture<Optional<Bar>> getBar() throws IOException { return completableFutureClient.get("http://localhost:9101/bar", new TypeReference<Optional<Bar>>() { });/*w w w . j a v a 2 s .c o m*/ }
From source file:spring.travel.site.services.AdvertService.java
public CompletableFuture<Optional<List<Advert>>> adverts(int count, Optional<Profile> profile) { return client.get(url(count, profile), new TypeReference<Optional<List<Advert>>>() { }).handle(withFallback(Optional.<List<Advert>>empty())); }