com.signalfx.shaded.fasterxml.jackson.databind.ser.std.SerializableSerializer Maven / Gradle / Ivy
Show all versions of signalfx-codahale Show documentation
package com.signalfx.shaded.fasterxml.jackson.databind.ser.std;
import java.io.IOException;
import com.signalfx.shaded.fasterxml.jackson.core.*;
import com.signalfx.shaded.fasterxml.jackson.databind.JavaType;
import com.signalfx.shaded.fasterxml.jackson.databind.JsonMappingException;
import com.signalfx.shaded.fasterxml.jackson.databind.JsonSerializable;
import com.signalfx.shaded.fasterxml.jackson.databind.SerializerProvider;
import com.signalfx.shaded.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import com.signalfx.shaded.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.signalfx.shaded.fasterxml.jackson.databind.jsontype.TypeSerializer;
/**
* Generic handler for types that implement {@link JsonSerializable}.
*
* Note: given that this is used for anything that implements
* interface, cannot be checked for direct class equivalence.
*/
@JacksonStdImpl
@SuppressWarnings("serial")
public class SerializableSerializer
extends StdSerializer
{
public final static SerializableSerializer instance = new SerializableSerializer();
protected SerializableSerializer() { super(JsonSerializable.class); }
@Override
public boolean isEmpty(SerializerProvider serializers, JsonSerializable value) {
if (value instanceof JsonSerializable.Base) {
return ((JsonSerializable.Base) value).isEmpty(serializers);
}
return false;
}
@Override
public void serialize(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
value.serialize(gen, serializers);
}
@Override
public final void serializeWithType(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers,
TypeSerializer typeSer) throws IOException {
value.serializeWithType(gen, serializers, typeSer);
}
@Override
public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint)
throws JsonMappingException
{
visitor.expectAnyFormat(typeHint);
}
}