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

net.n2oapp.framework.api.metadata.jackson.N2oNamespaceDeserializer 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.databind.DeserializationContext;
import com.fasterxml.jackson.databind.KeyDeserializer;
import net.n2oapp.framework.api.N2oNamespace;
import org.jdom2.Namespace;

import java.io.IOException;

/**
 * Десериализация N2oNamespace, необходима для Map
 */
public class N2oNamespaceDeserializer extends KeyDeserializer {

    private final String SEPARATOR = "$";

    @Override
    public N2oNamespace deserializeKey(
            String key,
            DeserializationContext ctxt) throws IOException {
        if (key.contains(SEPARATOR))
            return new N2oNamespace(Namespace.getNamespace(key.substring(0, key.indexOf(SEPARATOR)), key.substring(key.indexOf(SEPARATOR) + 1)));
        return new N2oNamespace(Namespace.getNamespace(key));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy