List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.evrythng.java.wrapper.service.PlaceService.java
/** * Retrieves the referenced {@link Place}. * <p>//from ww w . j ava2s .com * GET {@value #PATH_PLACE} * * @param placeId place id * @return a preconfigured {@link Builder} */ public Builder<Place> placeReader(final String placeId) throws EvrythngClientException { return get(String.format(PATH_PLACE, placeId), new TypeReference<Place>() { }); }
From source file:com.evrythng.java.wrapper.service.ProjectService.java
/** * Retrieves the referenced {@link Project} * <p>// ww w . j av a 2 s . co m * GET {@value #PATH_PROJECT} * * @param id project id * @return a preconfigured {@link Builder} */ public Builder<Project> projectReader(final String id) throws EvrythngClientException { return get(String.format(PATH_PROJECT, id), new TypeReference<Project>() { }); }
From source file:com.okta.sdk.clients.FactorsApiClient.java
public List<FactorCatalogEntry> getFactorsCatalog(String userId) throws IOException { return get(getEncodedPath("/%s/factors/catalog", userId), new TypeReference<List<FactorCatalogEntry>>() { });// w ww. j a v a2 s .co m }
From source file:plugins.marauders.MaraudersPUTServlet.java
@Override public HttpResponse handleRequest(HttpRequest request) { String body = new String(request.getBody()); ObjectMapper mapper = new ObjectMapper(); TypeReference<HashMap<String, Object>> typeReference = new TypeReference<HashMap<String, Object>>() { };/*from www. java2s.c o m*/ try { HashMap<String, Object> map = mapper.readValue(body, typeReference); String nameObj = (String) map.get("name"); String passphraseObj = (String) map.get("passphrase"); String houseObj = (String) map.get("house"); String locationObj = (String) map.get("location"); Student s = new Student(); s.setHouse(houseObj); s.setName(nameObj); s.setLocation(locationObj); Data d = MaraudersInteractor.getData(); boolean okPassphrase = passphraseObj.equals(d.passphrase); if (okPassphrase) { MaraudersInteractor.addStudent(s); return HttpResponseFactory.create204NoCon(Protocol.CLOSE); } else { Random rand = new Random(); int id = rand.nextInt(d.maxInsultID + 1); try { Insult i = MaraudersInteractor.getInsult(id + ""); File f = File.createTempFile("temp", ".txt"); FileOutputStream fos = new FileOutputStream(f); fos.write((i.toString()).getBytes()); fos.flush(); fos.close(); HttpResponse res = HttpResponseFactory.create394Insult(f, Protocol.CLOSE); //f.delete(); return res; } catch (Exception e) { e.printStackTrace(); return HttpResponseFactory.create400BadRequest(Protocol.CLOSE); } } } catch (Exception e) { e.printStackTrace(); } return HttpResponseFactory.create505NotSupported(Protocol.CLOSE); }
From source file:com.github.nmorel.gwtjackson.jackson.advanced.WildcardJacksonTest.java
@Test public void testSerializeGenericWildcard() { WildcardTester.INSTANCE//w ww. j a v a 2 s. c om .testSerializeGenericWildcard(createWriter(new TypeReference<GenericWildcard<Animal>>() { })); }
From source file:de.rallye.test.GroupsTest.java
@Test public void testGetGroups() throws IOException, DataException { StartTestServer.getServer();/*from w w w . j a v a2 s. co m*/ HttpResponse c = apiCall("groups", 200); List<Group> groups = mapper.readValue(c.getEntity().getContent(), new TypeReference<List<Group>>() { }); assertEquals("Returned Groups should be equal to source", data.getGroups(true), groups); }
From source file:net.mostlyharmless.jghservice.connector.github.GetMilestones.java
@Override public List<Milestone> processResponse(String jsonResponse) throws IOException { TypeReference<List<Milestone>> tr = new TypeReference<List<Milestone>>() { };//from w w w .j ava 2 s .c om ObjectMapper m = new ObjectMapperProvider().getContext(GithubEvent.Milestone.class); return m.readValue(jsonResponse, tr); }
From source file:com.auth0.api.internal.VoidRequest.java
public VoidRequest(Handler handler, HttpUrl url, OkHttpClient client, ObjectMapper mapper, String httpMethod) { super(handler, url, client, null, mapper.writer()); this.httpMethod = httpMethod; this.errorReader = mapper.reader(new TypeReference<Map<String, Object>>() { });/*from w w w . j a v a 2 s . c om*/ }
From source file:com.evrythng.java.wrapper.service.BatchService.java
/** * Retrieves {@link Batch} resources.//from w w w . j a v a2 s.c om * <p> * GET {@value #PATH_BATCHES} * * @return a preconfigured {@link Builder} */ public Builder<List<Batch>> batchesReader() throws EvrythngClientException { return get(PATH_BATCHES, new TypeReference<List<Batch>>() { }); }
From source file:com.twitter.ambrose.model.Job.java
public static Job fromJson(String json) throws IOException { return JSONUtil.toObject(json, new TypeReference<Job>() { });//from w w w .j a v a 2s .com }