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

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

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static <T> T read(String content, TypeReference<T> reference, MediaType contentType) throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isReadable(reference.getClass(), reference.getType(), null, contentType)) {
            return provider.locateMapper(reference.getClass(), contentType).readValue(content, reference);
        }/* www .  j  a v  a2 s . c  om*/
    }

    throw new IOException(String.format("no processors found for type=%s and Content-Type=%s",
            reference.getType(), contentType));
}

From source file:com.github.parisoft.resty.utils.JacksonUtils.java

public static <T> T read(HttpEntity entity, TypeReference<T> reference, MediaType contentType)
        throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isReadable(reference.getClass(), reference.getType(), null, contentType)) {
            return provider.locateMapper(reference.getClass(), contentType).readValue(entity.getContent(),
                    reference);// w  w w . java  2s.  c  om
        }
    }

    throw new IOException(String.format("no processors found for type=%s and Content-Type=%s",
            reference.getType(), contentType));
}