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

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

Introduction

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

Prototype

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

Source Link

Document

Returns the runtime class of this Object .

Usage

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 ww  .j  a  v  a  2s.co  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)//from  ww  w  .  j  av  a2  s .  c o  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;
}