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.jackson.advanced.jsontype.JsonTypeWithGenericsJacksonTest.java

@Test
public void testWrapperWithGetter() {
    JsonTypeWithGenericsTester.INSTANCE/*from   w w w . j a  va 2  s .com*/
            .testWrapperWithGetter(createMapper(new TypeReference<ContainerWithGetter<Animal>>() {
            }));
}

From source file:spring.travel.site.services.LoyaltyService.java

public CompletableFuture<Optional<Loyalty>> loyalty(Optional<User> user) {
    return user.<CompletableFuture<Optional<Loyalty>>>map(
            u -> client.get(url(u), new TypeReference<Optional<Loyalty>>() {
            }).handle(withFallback(Optional.<Loyalty>empty()))).orElse(none());
}

From source file:spring.travel.site.services.ProfileService.java

public CompletableFuture<Optional<Profile>> profile(Optional<User> user) {
    return user.<CompletableFuture<Optional<Profile>>>map(
            u -> client.get(url(u), new TypeReference<Optional<Profile>>() {
            }).handle(withFallback(Optional.<Profile>empty()))).orElse(none());
}

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

@Override
protected CompletableFuture<Optional<User>> login(Login login) throws IOException {
    String body = objectMapper.writeValueAsString(login);
    return completableFutureClient
            .post("http://localhost:9101/user/login", body, new TypeReference<Optional<User>>() {
            }).handle(withFallback(Optional.<User>empty()));
}

From source file:com.github.nmorel.gwtjackson.guava.jackson.ImmutablesJacksonTest.java

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

From source file:com.globo.globodns.client.api.RecordAPI.java

@Override
protected Type getType() {
    return new TypeReference<Record>() {
    }.getType();
}

From source file:spring.travel.site.services.OffersService.java

public CompletableFuture<Optional<List<Offer>>> offers(Optional<Profile> profile, Optional<Loyalty> loyalty) {
    return client.get(url(profile, loyalty), new TypeReference<Optional<List<Offer>>>() {
    }).handle(withFallback(Optional.<List<Offer>>empty()));
}

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

/**
 * Creates a new {@link Project}/*from www  . j av a2 s . c  o  m*/
 * <p>
 * POST {@value #PATH_PROJECTS}
 *
 * @param project {@link Project} instance
 * @return a preconfigured {@link Builder}
 */
public Builder<Project> projectCreator(final Project project) throws EvrythngClientException {

    return post(PATH_PROJECTS, project, new TypeReference<Project>() {

    });
}

From source file:org.fede.calculator.money.bls.JSONBlsCPISource.java

@Override
public BlsResponse getResponse(int year) throws IOException {
    if (this.list == null) {
        try (InputStream in = JSONBlsCPISource.class.getResourceAsStream("/" + name)) {
            this.list = new ObjectMapper().readValue(in, new TypeReference<List<BlsResponse>>() {
            });/*from  w  ww  . java  2s.c  o m*/
        }
    }

    return this.list.stream().filter(response -> response.getDataPoint(CPI_SERIES_ID, year, 1) != null)
            .findFirst().orElse(null);

}

From source file:tachyon.master.InodeFolder.java

/**
 * Create a new InodeFile from a JsonParser and an image Json element.
 *
 * @param parser the JsonParser to get the next element
 * @param ele the current InodeFolder's Json image element.
 * @return the constructed InodeFolder.//  w ww .  j a  v  a  2s .  c o m
 * @throws IOException
 */
static InodeFolder loadImage(JsonParser parser, ImageElement ele) throws IOException {
    final long creationTimeMs = ele.getLong("creationTimeMs");
    final int fileId = ele.getInt("id");
    final boolean isPinned = ele.getBoolean("pinned");
    final String fileName = ele.getString("name");
    final int parentId = ele.getInt("parentId");
    List<Integer> childrenIds = ele.get("childrenIds", new TypeReference<List<Integer>>() {
    });
    final long lastModificationTimeMs = ele.getLong("lastModificationTimeMs");
    int numberOfChildren = childrenIds.size();
    Inode[] children = new Inode[numberOfChildren];
    for (int k = 0; k < numberOfChildren; k++) {
        try {
            ele = parser.readValueAs(ImageElement.class);
            LOG.debug("Read Element: {}", ele);
        } catch (IOException e) {
            throw e;
        }

        switch (ele.mType) {
        case InodeFile: {
            children[k] = InodeFile.loadImage(ele);
            break;
        }
        case InodeFolder: {
            children[k] = InodeFolder.loadImage(parser, ele);
            break;
        }
        default:
            throw new IOException("Invalid element type " + ele);
        }
    }

    InodeFolder folder = new InodeFolder(fileName, fileId, parentId, creationTimeMs);
    folder.setPinned(isPinned);
    folder.addChildren(children);
    folder.setLastModificationTimeMs(lastModificationTimeMs);
    return folder;
}