List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference
protected TypeReference()
From source file:com.hortonworks.streamline.streams.common.event.EventLogFileReader.java
public Stream<EventInformation> loadEventLogFileAsStream(File eventLogFile) throws IOException { Stream<String> lines = Files.lines(eventLogFile.toPath(), ENCODING_UTF_8); return lines.map(line -> { try {/* w w w .ja va2 s. co m*/ return (EventInformation) objectMapper.readValue(line, new TypeReference<EventInformation>() { }); } catch (IOException e) { throw new RuntimeException(e); } }); }
From source file:com.dssmp.agent.config.Configuration.java
/** * Build a configuration from an input stream containing JSON. * * @param is/*from w ww . ja va2 s. com*/ * @return * @throws IOException */ @SuppressWarnings("unchecked") public static Configuration get(InputStream is) throws IOException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true); return new Configuration( (Map<String, Object>) mapper.readValue(is, new TypeReference<HashMap<String, Object>>() { })); }
From source file:test.com.wealdtech.jackson.modules.WIDModuleTest.java
@Test public void testDeserWID() throws Exception { final String ser = "\"a2a19b20000000a\""; final WID<Date> deser = this.mapper.readValue(ser, new TypeReference<WID<Date>>() { });/*from www . j a v a 2 s . co m*/ assertEquals(deser, WID.<Date>fromComponents(5, 1500000000000L, 10)); }
From source file:fi.helsinki.opintoni.integration.unisport.UnisportMockClient.java
@Override public Optional<UnisportUser> getUnisportUserByPrincipal(String username) { if (username.equals("opettaja@helsinki.fi")) { return Optional.ofNullable(null); } else {/*from ww w . j a v a 2 s. co m*/ return Optional.ofNullable(getResponse(userResource, new TypeReference<UnisportUser>() { })); } }
From source file:org.agorava.facebook.jackson.ReferenceListDeserializer.java
@SuppressWarnings("unchecked") @Override// ww w . j av a 2 s . c om public List<Reference> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = getInstance().resolve(ObjectMapper.class); jp.setCodec(mapper); if (jp.hasCurrentToken()) { JsonNode dataNode = (JsonNode) jp.readValueAs(JsonNode.class).get("data"); if (dataNode != null) { return (List<Reference>) mapper.reader(new TypeReference<List<Reference>>() { }).readValue(dataNode); } } return Collections.emptyList(); }
From source file:com.addthis.bundle.util.AutoFieldTest.java
@Test public void createConstantTyped() throws IOException { ConstantTypedField<List<String>> autoField = Jackson.defaultMapper().readValue("\"someConst\"", new TypeReference<ConstantTypedField<List<String>>>() { });/*from ww w . j a v a 2 s .c om*/ assertEquals(Lists.newArrayList("someConst"), autoField.getValue(null)); }
From source file:com.globo.aclapi.client.api.RuleAPI.java
@Override protected Type getType() { return new TypeReference<Rule>() { }.getType(); }
From source file:com.evrythng.java.wrapper.service.ProjectService.java
/** * Retrieves list of all {@link Project} resources. * <p>/*from w ww.ja v a2 s . co m*/ * GET {@value #PATH_PROJECTS} * * @return a preconfigured {@link Builder} */ public Builder<List<Project>> projectsReader() throws EvrythngClientException { return get(PATH_PROJECTS, new TypeReference<List<Project>>() { }); }
From source file:com.meltmedia.dropwizard.etcd.json.EtcdDirectoryIT.java
@Before public void setUp() { directory = factoryRule.getFactory().newDirectory("/test/data", new TypeReference<NodeData>() { });// w w w . j a v a2s . co m dao = directory.newDao(); }
From source file:org.springframework.social.facebook.api.impl.json.ReferenceListDeserializer.java
@SuppressWarnings("unchecked") @Override//from ww w. java 2s.c o m public List<Reference> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new FacebookModule()); jp.setCodec(mapper); if (jp.hasCurrentToken()) { JsonNode dataNode = (JsonNode) jp.readValueAs(JsonNode.class).get("data"); if (dataNode != null) { return (List<Reference>) mapper.reader(new TypeReference<List<Reference>>() { }).readValue(dataNode); } } return Collections.emptyList(); }