Example usage for com.fasterxml.jackson.core.type TypeReference TypeReference

List of usage examples for com.fasterxml.jackson.core.type TypeReference TypeReference

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core.type TypeReference TypeReference.

Prototype

protected TypeReference() 

Source Link

Usage

From source file:com.liferay.sync.engine.util.SyncClientUpdater.java

public static SyncVersion getLatestSyncVersion() throws Exception {
    HttpResponse httpResponse = execute(PropsValues.SYNC_UPDATE_CHECK_URL);

    if (httpResponse == null) {
        return null;
    }//from  ww w .ja  v  a  2 s.c  o  m

    ObjectMapper objectMapper = new ObjectMapper();

    HttpEntity httpEntity = httpResponse.getEntity();

    return objectMapper.readValue(httpEntity.getContent(), new TypeReference<SyncVersion>() {
    });
}

From source file:com.okta.sdk.clients.SessionApiClient.java

public Session createSessionForMe() throws IOException {
    return post(getEncodedPath("/me"), null, new TypeReference<Session>() {
    });//from   w w  w  . j  a v  a 2s . com
}

From source file:com.playonlinux.apps.InstallerSourceWebserviceDefaultImplementation.java

@Override
protected TypeReference<List<CategoryDTO>> defineTypeReference() {
    return new TypeReference<List<CategoryDTO>>() {

    };
}

From source file:com.evrythng.java.wrapper.service.PlaceService.java

/**
 * Creates a new {@link Place}./*from   www. ja v a2s . c  o m*/
 * <p>
 * POST {@value #PATH_PLACES}
 *
 * @param place {@link Place} instance
 * @return a preconfigured {@link Builder}
 */
public Builder<Place> placeCreator(final Place place) throws EvrythngClientException {

    return post(PATH_PLACES, place, new TypeReference<Place>() {

    });
}

From source file:com.netflix.suro.message.TestJsonSerDe.java

@Test
public void test() throws IOException {
    String obj = "{\n" + "    \"field1\": \"value1\",\n" + "    \"field2\": 3,\n" + "    \"field3\": {\n"
            + "        \"field3_1\": \"value3_1\",\n" + "        \"field3_2\": \"value3_2\"\n" + "    }\n"
            + "}";

    ObjectMapper jsonMapper = new DefaultObjectMapper();
    TypeReference<Map<String, Object>> type = new TypeReference<Map<String, Object>>() {
    };/* w w w  .  j  av a  2  s . c  om*/
    Map<String, Object> map = jsonMapper.readValue(obj, type);
    assertEquals(map.get("field2"), 3); // just check whether the object is created properly

    JsonSerDe<Map<String, Object>> serde = new JsonSerDe<Map<String, Object>>();
    byte[] bytes = serde.serialize(map);
    Map<String, Object> map2 = jsonMapper.readValue(bytes, type);
    assertEquals(map, map2);

    map2 = serde.deserialize(bytes);
    assertEquals(map, map2);

    assertEquals(obj.replaceAll("[\\t\\r\\n ]", ""), serde.toString(bytes));
}

From source file:org.redisson.spring.cache.CacheConfigSupport.java

public Map<String, CacheConfig> fromJSON(File file) throws IOException {
    return jsonMapper.readValue(file, new TypeReference<Map<String, CacheConfig>>() {
    });/*  w  w w .  j a  v a  2  s.c om*/
}

From source file:com.hortonworks.streamline.streams.layout.component.TopologyLayout.java

public TopologyLayout(Long id, String name, String configStr, TopologyDag topologyDag) throws IOException {
    this.id = id;
    this.name = name;
    if (!StringUtils.isEmpty(configStr)) {
        ObjectMapper mapper = new ObjectMapper();
        Map<String, Object> properties = mapper.readValue(configStr, new TypeReference<Map<String, Object>>() {
        });/*from  www .  j ava  2  s.  c  om*/
        config = new Config();
        config.putAll(properties);
    } else {
        config = new Config();
    }
    this.topologyDag = topologyDag;
}

From source file:org.mayocat.configuration.internal.AbstractConfigurationTest.java

protected Map<String, Serializable> getConfiguration(GeneralSettings configuration) throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    String asJson = mapper.writeValueAsString(configuration);
    Map<String, Serializable> configurationAsJson = mapper.readValue(asJson,
            new TypeReference<Map<String, Object>>() {
            });//  w  ww.j  a v a 2  s.co m
    return configurationAsJson;
}

From source file:de.dfki.asr.compass.rest.serialization.RenderGeometryDeserializer.java

@Override
public RenderGeometry deserialize(final JsonParser jp, final DeserializationContext ctxt)
        throws IOException, JsonProcessingException {
    ObjectCodec oc = jp.getCodec();/*  ww  w .j a  v  a  2  s  . co m*/
    Long id = oc.readValue(jp, new TypeReference<Long>() {
    });
    try {
        return (RenderGeometry) manager.referenceById(id);
    } catch (EntityNotFoundException e) {
        throw new IOException("Cannot load from Database", e);
    }
}

From source file:com.cognifide.qa.bb.modules.BobcatRunModule.java

@Override
protected void configure() {
    String runmodes = System.getProperty("runmode", "default");
    String[] separateRunModes = StringUtils.split(runmodes, ",");
    List<String> modules = new ArrayList<>();
    TypeReference typeReference = new TypeReference<List<String>>() {
    };/*from   w ww.  j av a  2  s. com*/
    Arrays.stream(separateRunModes).forEach(
            runmode -> modules.addAll(YamlReader.readFromTestResources("runmodes/" + runmode, typeReference)));
    modules.stream().forEach(this::installFromName);
}