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

net.n2oapp.framework.api.metadata.jackson.N2oNamespaceSerializer Maven / Gradle / Ivy

There is a newer version: 7.28.2
Show newest version
package net.n2oapp.framework.api.metadata.jackson;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import net.n2oapp.framework.api.N2oNamespace;

import java.io.IOException;

/**
 * Cериализация N2oNamespace, необходима для Map
 */
public class N2oNamespaceSerializer extends JsonSerializer {

    @Override
    public void serialize(N2oNamespace n2oNamespace, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
            throws IOException {
        String namespace;
        if (n2oNamespace.getPrefix() == null) {
            namespace = n2oNamespace.getUri();
        } else {
            namespace = n2oNamespace.getPrefix() + "$" + n2oNamespace.getUri();
        }
        jsonGenerator.writeFieldName(namespace);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy