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

pl.fhframework.model.forms.attributes.AttributeHolderSerializer Maven / Gradle / Ivy

There is a newer version: 4.10.401
Show newest version
package pl.fhframework.model.forms.attributes;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;

import java.io.IOException;
import java.util.Collection;
import java.util.Map;

public class AttributeHolderSerializer extends StdSerializer, Attribute>> {
    public AttributeHolderSerializer() {
        this(null);
    }

    protected AttributeHolderSerializer(Class, Attribute>> t) {
        super(t);
    }

    @Override
    public void serialize(Map, Attribute> attributes, JsonGenerator jgen, SerializerProvider provider) throws IOException {
        jgen.writeStartObject();

        final Collection values = attributes.values();
        for (Attribute value : values) {
            jgen.writeObjectField(value.getXmlValue(), value.getValue());
        }
        jgen.writeEndObject();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy