com.fitbur.fasterxml.jackson.databind.ser.std.EnumSetSerializer Maven / Gradle / Ivy
package com.fitbur.fasterxml.jackson.databind.ser.std;
import java.io.IOException;
import java.util.EnumSet;
import com.fitbur.fasterxml.jackson.core.*;
import com.fitbur.fasterxml.jackson.databind.*;
import com.fitbur.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
© 2015 - 2024 Weber Informatics LLC | Privacy Policy