com.fasterxml.jackson.databind.ser.std.EnumSetSerializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisson-all Show documentation
Show all versions of redisson-all Show documentation
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
package com.fasterxml.jackson.databind.ser.std;
import java.io.IOException;
import java.util.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
@SuppressWarnings("serial")
public class EnumSetSerializer
extends AsArraySerializerBase>>
{
/**
* @since 2.6
*/
public EnumSetSerializer(JavaType elemType) {
super(EnumSet.class, elemType, true, null, null);
}
public EnumSetSerializer(EnumSetSerializer src,
BeanProperty property, TypeSerializer vts, JsonSerializer> valueSerializer,
Boolean unwrapSingle) {
super(src, property, vts, valueSerializer, unwrapSingle);
}
@Override
public EnumSetSerializer _withValueTypeSerializer(TypeSerializer vts) {
// no typing for enums (always "hard" type)
return this;
}
@Override
public EnumSetSerializer withResolved(BeanProperty property,
TypeSerializer vts, JsonSerializer> elementSerializer,
Boolean unwrapSingle) {
return new EnumSetSerializer(this, property, vts, elementSerializer, unwrapSingle);
}
@Override
public boolean isEmpty(SerializerProvider prov, EnumSet extends Enum>> value) {
return value.isEmpty();
}
@Override
public boolean hasSingleElement(EnumSet extends Enum>> value) {
return value.size() == 1;
}
@Override
public final void serialize(EnumSet extends Enum>> value, JsonGenerator gen,
SerializerProvider provider) throws IOException
{
final int len = value.size();
if (len == 1) {
if (((_unwrapSingle == null)
&& provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED))
|| (_unwrapSingle == Boolean.TRUE)) {
serializeContents(value, gen, provider);
return;
}
}
gen.writeStartArray(value, len);
serializeContents(value, gen, provider);
gen.writeEndArray();
}
@Override
public void serializeContents(EnumSet extends Enum>> value, JsonGenerator gen,
SerializerProvider provider)
throws IOException
{
JsonSerializer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy