Example usage for com.fasterxml.jackson.databind JsonSerializer handledType

List of usage examples for com.fasterxml.jackson.databind JsonSerializer handledType

Introduction

In this page you can find the example usage for com.fasterxml.jackson.databind JsonSerializer handledType.

Prototype

public Class<T> handledType() 

Source Link

Usage

From source file:com.proofpoint.json.JsonBinder.java

public <T> void bindSerializer(JsonSerializer<T> jsonSerializer) {
    Preconditions.checkNotNull(jsonSerializer, "jsonSerializer is null");

    Class<?> type = jsonSerializer.handledType();
    Preconditions.checkNotNull(type, "jsonSerializer.handledType is null");
    Preconditions.checkArgument(type == Object.class, "jsonSerializer.handledType can not be Object.class");
    serializerMapBinder.addBinding(type).toInstance(jsonSerializer);
}

From source file:org.springframework.yarn.integration.support.Jackson2ObjectMapperFactoryBean.java

/**
 * Configure custom serializers. Each serializer is registered for the type
 * returned by {@link JsonSerializer#handledType()}, which must not be
 * {@code null}.//  w  w w  . j  av  a2  s. c  o m
 * @see #setSerializersByType(Map)
 */
public void setSerializers(JsonSerializer<?>... serializers) {
    if (serializers != null) {
        for (JsonSerializer<?> serializer : serializers) {
            Class<?> handledType = serializer.handledType();
            Assert.isTrue(handledType != null && handledType != Object.class,
                    "Unknown handled type in " + serializer.getClass().getName());
            this.serializers.put(serializer.handledType(), serializer);
        }
    }
}

From source file:org.springframework.http.converter.json.Jackson2ObjectMapperBuilder.java

/**
 * Configure custom serializers. Each serializer is registered for the type
 * returned by {@link JsonSerializer#handledType()}, which must not be {@code null}.
 * @see #serializersByType(Map)// w ww.  j a  va  2 s .co m
 */
public Jackson2ObjectMapperBuilder serializers(JsonSerializer<?>... serializers) {
    for (JsonSerializer<?> serializer : serializers) {
        Class<?> handledType = serializer.handledType();
        if (handledType == null || handledType == Object.class) {
            throw new IllegalArgumentException("Unknown handled type in " + serializer.getClass().getName());
        }
        this.serializers.put(serializer.handledType(), serializer);
    }
    return this;
}