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.github.nmorel.gwtjackson.guava.jackson.ImmutablesJacksonTest.java

@Test
public void testImmutableSet() {
    ImmutablesTester.INSTANCE.testImmutableSet(createMapper(new TypeReference<ImmutableSet<Integer>>() {
    }));
}

From source file:com.wrmsr.neurosis.aws.ec2.Ec2InstanceTypeDetails.java

public static Map<String, Ec2InstanceTypeDetails> read() throws IOException {
    List<Ec2InstanceTypeDetails> lst;
    try (InputStream in = Ec2InstanceTypeDetails.class.getClassLoader().getResourceAsStream(RESOURCE)) {
        lst = Serialization.JSON_OBJECT_MAPPER.get().readValue(in,
                new TypeReference<List<Ec2InstanceTypeDetails>>() {
                });/*from   w  w  w.j  a  v a 2s. com*/
    }
    return lst.stream().map(i -> new ImmutablePair<>(i.instanceType, i)).collect(toImmutableMap());
}

From source file:com.acme.legacy.app.repository.JsonUserRepository.java

@PostConstruct
@SuppressWarnings("unchecked")
public void init() throws Exception {
    Resource resource = new ClassPathResource("users.json");
    ObjectMapper mapper = Jackson2ObjectMapperBuilder.json().build();
    List<User> userList = mapper.readValue(resource.getInputStream(), new TypeReference<List<User>>() {
    });/*from  w w w .  ja v a  2  s .  c o  m*/
    Map<String, User> userMap = new TreeMap<>();

    for (User user : userList)
        userMap.put(user.getEmail(), user);

    this.users = Collections.unmodifiableMap(userMap);
}

From source file:com.pinterest.secor.parser.MessagePackParser.java

public MessagePackParser(SecorConfig config) {
    super(config);
    mMessagePackObjectMapper = new ObjectMapper(new MessagePackFactory());
    mTypeReference = new TypeReference<HashMap<String, Object>>() {
    };/*www. ja va2s .c o  m*/
}

From source file:JacksonJacksumTest.java

@BeforeClass
public static void setUpClass() throws IOException {

    List<HashResultHolder> list = new ObjectMapper().readValue(
            JacksonJacksumTest.class.getResourceAsStream("/jacksum_image.json"),
            new TypeReference<List<HashResultHolder>>() {
            });/*from w ww .  java  2s. com*/

    IMAGE_FILE_RESULTS = list.stream()
            .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity()));

    /*Map<String, String> map = JacksumAPI.getAvailableAlgorithms();
     map.keySet().stream()
     .forEach(cannonicalName -> System.out.println(cannonicalName.toUpperCase()+"(\""+map.get(cannonicalName)+"\",\""+cannonicalName+"\", \"alias\"),"));
     */
    /*JacksumAPI.getAvailableAlgorithms().keySet().stream()
     .forEach(name -> System.out.println("@Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MILLISECONDS)  public String "+name+"FileAlt() {return this.getFileHashValue(this.getChecksum(\""+name+"\", true), FILE);}"));
     */
    //        IMAGE_FILE_RESULTS.keySet().stream().forEach(str -> System.out.println("@Test public void test_" + str + "(){this.individualTest(\"" + str + "\");}"));
    list = new ObjectMapper().readValue(JacksonJacksumTest.class.getResourceAsStream("/jacksum_text.json"),
            new TypeReference<List<HashResultHolder>>() {
            });

    TEXT_FILE_RESULTS = list.stream()
            .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity()));

    list = new ObjectMapper().readValue(JacksonJacksumTest.class.getResourceAsStream("/jacksum_string.json"),
            new TypeReference<List<HashResultHolder>>() {
            });

    STRING_RESULTS = list.stream()
            .collect(Collectors.toMap(HashResultHolder::getAlgorithm, Function.identity()));

}

From source file:uk.co.sdev.async.http.ning.Parallel3CompletableFutureClientTest.java

@Override
protected CompletableFuture<Optional<Weather>> getWeather() throws IOException {
    return completableFutureClient.get("http://localhost:9101/weather", new TypeReference<Optional<Weather>>() {
    });// w w w.  j  ava2 s .c  o m
}

From source file:com.vmware.photon.controller.api.client.resource.AuthApi.java

/**
 * Get auth status./*from www .  j a va 2 s  .  com*/
 *
 * @return {@link Auth} details.
 * @throws IOException
 */
public Auth getAuthStatus() throws IOException {
    String path = getBasePath();

    HttpResponse httpResponse = this.restClient.perform(RestClient.Method.GET, path, null);
    this.restClient.checkResponse(httpResponse, HttpStatus.SC_OK);

    return this.restClient.parseHttpResponse(httpResponse, new TypeReference<Auth>() {
    });
}

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

public Session createSessionForMeWithAdditionalFields(String additionalFields) throws IOException {
    return post(getEncodedPath("/me?additionalFields=%s", additionalFields), null,
            new TypeReference<Session>() {
            });//from   w w w. j  av a  2  s. co  m
}

From source file:org.fasterxml.jackson.tc.TreeTest.java

@Test
public void tree() throws Exception {

    Map<KeyEnum, Object> inputMap = Maps.newHashMap();
    Map<TestEnum, Map<String, String>> replacements = Maps.newHashMap();
    Map<String, String> reps = Maps.newHashMap();
    reps.put("1", "one");
    replacements.put(TestEnum.GREEN, reps);
    inputMap.put(KeyEnum.replacements, replacements);

    Bean bean = transcodeFromMap(inputMap, new TypeReference<Bean>() {
    });/*  w  w w  . j  av  a2  s .  co  m*/
    assertNotNull(bean);
}

From source file:org.springframework.cloud.config.monitor.GitlabPropertyPathNotificationExtractorTests.java

@Test
public void pushEvent() throws Exception {
    // See http://doc.gitlab.com/ee/web_hooks/web_hooks.html#push-events
    Map<String, Object> value = new ObjectMapper().readValue(
            new ClassPathResource("gitlab.json").getInputStream(), new TypeReference<Map<String, Object>>() {
            });/*from ww  w  .j a va  2  s.c  om*/
    this.headers.set("X-Gitlab-Event", "Push Hook");
    PropertyPathNotification extracted = this.extractor.extract(this.headers, value);
    assertNotNull(extracted);
    String[] paths = extracted.getPaths();
    assertThat("paths was wrong", paths,
            arrayContainingInAnyOrder("oldapp.yml", "newapp.properties", "application.yml"));
}