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 jersey-all Show documentation
Show all versions of jersey-all Show documentation
jersey-all is a rebundled verison of Jersey as one OSGi bundle.
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