org.codehaus.jackson.map.ser.std.IterableSerializer Maven / Gradle / Ivy
Go to download
Data Mapper package is a high-performance data binding package
built on Jackson JSON processor
package org.codehaus.jackson.map.ser.std;
import java.io.IOException;
import java.util.Iterator;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.BeanProperty;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.TypeSerializer;
import org.codehaus.jackson.map.annotate.JacksonStdImpl;
import org.codehaus.jackson.type.JavaType;
@JacksonStdImpl
public class IterableSerializer
extends AsArraySerializerBase>
{
public IterableSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts, BeanProperty property)
{
super(Iterable.class, elemType, staticTyping, vts, property, null);
}
@Override
public ContainerSerializerBase> _withValueTypeSerializer(TypeSerializer vts) {
return new IterableSerializer(_elementType, _staticTyping, vts, _property);
}
@Override
public void serializeContents(Iterable> value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
{
Iterator> it = value.iterator();
if (it.hasNext()) {
final TypeSerializer typeSer = _valueTypeSerializer;
JsonSerializer
© 2015 - 2024 Weber Informatics LLC | Privacy Policy