Example usage for com.fasterxml.jackson.jaxrs.base ProviderBase isWriteable

List of usage examples for com.fasterxml.jackson.jaxrs.base ProviderBase isWriteable

Introduction

In this page you can find the example usage for com.fasterxml.jackson.jaxrs.base ProviderBase isWriteable.

Prototype

@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) 

Source Link

Document

Method that JAX-RS container calls to try to check whether given value (of specified type) can be serialized by this provider.

Usage

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

public static String write(Object object, MediaType contentType) throws IOException {
    for (ProviderBase<?, ?, ?, ?> provider : DataProcessors.getInstance().values()) {
        if (provider.isWriteable(object.getClass(), null, null, contentType)) {
            return provider.locateMapper(object.getClass(), contentType).writeValueAsString(object);
        }//www .j  a  v  a  2  s. c  o  m
    }

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