List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.vmware.photon.controller.api.client.resource.DisksRestApi.java
/** * Get details about the specified disk. * * @param diskId// w ww . j ava 2s. c o m * @return Disk details * @throws java.io.IOException */ @Override public PersistentDisk getDisk(String diskId) throws IOException { String path = String.format("%s/%s", getBasePath(), diskId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse(httpResponse, new TypeReference<PersistentDisk>() { }); }
From source file:com.vmware.photon.controller.api.client.resource.AuthRestApi.java
/** * Get auth status asynchronously.//from www. j a va 2 s. c om * * @param responseCallback * @throws IOException */ @Override public void getAuthStatusAsync(final FutureCallback<Auth> responseCallback) throws IOException { String path = getBasePath(); getObjectByPathAsync(path, responseCallback, new TypeReference<Auth>() { }); }
From source file:test.com.wealdtech.jackson.modules.JacksonModulesTest.java
@Test public void testDeserAbsent() throws Exception { final Optional<?> value = this.mapper.readValue("null", new TypeReference<Optional<String>>() { });/*from w ww . ja va 2 s . c o m*/ assertFalse(value.isPresent()); }
From source file:com.auth0.lock.passwordless.task.LoadCountriesTask.java
@Override protected Map<String, String> doInBackground(String... params) { Map<String, String> codes; try {/*from w ww.ja va 2 s . c om*/ TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() { }; codes = new ObjectMapper().readValue(context.getAssets().open(params[0]), typeRef); Log.d(TAG, "Loaded " + codes.size() + " countries"); } catch (IOException e) { codes = new HashMap<>(); Log.e(TAG, "Failed to load countries JSON file", e); } return codes; }
From source file:io.kyligence.benchmark.loadtest.util.JsonUtil.java
public static Map<String, String> readValueAsMap(String content) throws IOException { TypeReference<HashMap<String, String>> typeRef = new TypeReference<HashMap<String, String>>() { };// w w w .j a va2 s . c om return mapper.readValue(content, typeRef); }
From source file:com.netflix.suro.sink.remotefile.TestPrefixFormatter.java
@Test public void testDynamicStatic() throws IOException { String spec = "{\n" + " \"type\": \"dynamic\",\n" + " \"format\": \"static(prefix)\"\n" + "}"; ObjectMapper mapper = injector.getInstance(ObjectMapper.class); RemotePrefixFormatter formatter = mapper.readValue(spec, new TypeReference<RemotePrefixFormatter>() { });/*from w ww . j a v a 2 s . c o m*/ assertEquals(formatter.get(), "prefix/"); }
From source file:com.vmware.photon.controller.api.client.resource.ResourceTicketApi.java
/** * Get details about the specified resource ticket. * * @param resourceTicketId// ww w. j av a2s .c o m * @return Resource ticket details * @throws IOException */ public ResourceTicket getResourceTicket(String resourceTicketId) throws IOException { String path = String.format("%s/%s", getBasePath(), resourceTicketId); HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null); this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK); return this.restClient.parseHttpResponse(httpResponse, new TypeReference<ResourceTicket>() { }); }
From source file:rest.ProjectREST.java
private Project getFormattedDataSingle(Response response) { String responseJson = response.readEntity(String.class); System.out.println(responseJson); ObjectMapper mapper = new ObjectMapper(); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { };//from w ww . java 2 s.c o m StringBuilder sb = new StringBuilder(); try { HashMap<String, Object> map = mapper.readValue(responseJson, typeReference); if (Boolean.parseBoolean(map.get("found").toString())) { return Project.parseProject(map); // } else { return null; } } catch (Exception e) { return null; } }
From source file:plugins.marauders.MaraudersInteractor.java
public static Data getData() { StringBuilder json = new StringBuilder(); try {/*from w w w . ja v a 2 s. c om*/ URL server = new URL("http://s40server.csse.rose-hulman.edu:9200/marauders/data/0"); URLConnection yc = server.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null && inputLine != "") { System.out.println(inputLine); json.append(inputLine); } in.close(); } catch (Exception e) { e.printStackTrace(); } ObjectMapper mapper = new ObjectMapper(); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { }; try { HashMap<String, Object> map = mapper.readValue(json.toString(), typeReference); HashMap<String, Object> source = (HashMap) map.get("_source"); Data d = new Data(); d.setLastStudentID(Integer.parseInt((String) source.get("lastStudentID"))); d.setMaxInsultID(Integer.parseInt((String) source.get("maxInsultID"))); d.setPassphrase((String) source.get("passphrase")); return d; } catch (IOException e) { e.printStackTrace(); return null; } }
From source file:fi.helsinki.opintoni.integration.leiki.LeikiMockClient.java
@Override public List<LeikiCategoryHit> searchCategory(String searchTerm, Locale locale) { return getLeikiCategoryResponse(categoryResultsResource, new TypeReference<LeikiCategoryResponse<LeikiCategoryHit>>() { });/* w w w .ja v a 2 s . c om*/ }