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 ehcache Show documentation
Show all versions of ehcache Show documentation
Ehcache is an open source, standards-based cache used to boost performance,
offload the database and simplify scalability. Ehcache is robust, proven and full-featured and
this has made it the most widely-used Java-based cache.
package com.fasterxml.jackson.databind.ser.std;
import java.io.IOException;
import java.util.EnumSet;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
public class EnumSetSerializer
extends AsArraySerializerBase>>
{
public EnumSetSerializer(JavaType elemType, BeanProperty property)
{
super(EnumSet.class, elemType, true, null, property, null);
}
public EnumSetSerializer(EnumSetSerializer src,
BeanProperty property, TypeSerializer vts, JsonSerializer> valueSerializer)
{
super(src, property, vts, valueSerializer);
}
@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) {
return new EnumSetSerializer(this, property, vts, elementSerializer);
}
@Override
public boolean isEmpty(EnumSet extends Enum>> value) {
return (value == null) || value.isEmpty();
}
@Override
public boolean hasSingleElement(EnumSet extends Enum>> value) {
return value.size() == 1;
}
@Override
public void serializeContents(EnumSet extends Enum>> value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
JsonSerializer