All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.anotheria.anodoc.util.mapper.ps.ListPropertySerializer Maven / Gradle / Ivy

There is a newer version: 4.3.0
Show newest version
package net.anotheria.anodoc.util.mapper.ps;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import net.anotheria.anodoc.data.ListProperty;
import net.anotheria.anodoc.data.Property;

import java.io.IOException;

/**
 * @author ykalapusha
 */
public class ListPropertySerializer extends StdSerializer {

    public ListPropertySerializer() {
        this(null);
    }

    public ListPropertySerializer(Class t) {
        super(t);
    }

    @Override
    public void serialize (ListProperty value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeStartObject();
        jgen.writeArrayFieldStart(value.getId());
        for (Property element: value.getList()) {
            jgen.writeObject(element);
        }
        jgen.writeEndArray();
        jgen.writeStringField("type", value.getPropertyType().toString());
        jgen.writeEndObject();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy