All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.jackson.databind.ser.std.SerializableSerializer Maven / Gradle / Ivy

Go to download

Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava3/Reactive API. Client side caching. Over 50 Redis based Java objects and services: JCache API, Apache Tomcat, Hibernate, Spring, Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Scheduler, RPC

There is a newer version: 3.40.2
Show newest version
package com.fasterxml.jackson.databind.ser.std;

import java.io.IOException;

import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializable;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.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); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy