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

nl.vpro.domain.media.update.bind.LanguageList Maven / Gradle / Ivy

Go to download

The basic domain classes for 'media', the core of POMS. Also, the 'update' XML bindings for it. It also contains some closely related domain classes like the enum to contain NICAM kijkwijzer settings.

There is a newer version: 8.3.1
Show newest version
package nl.vpro.domain.media.update.bind;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.*;

import nl.vpro.domain.bind.AbstractJsonIterable;
import nl.vpro.domain.media.UsedLanguage;


/**
 * Might not be needed. It seems that the only thing is currently arranges is that the empy list causes [].
 * @author Michiel Meeuwissen
 * @since 8.2
 */
public class LanguageList {

    private LanguageList() {
    }

    public static class Serializer extends AbstractJsonIterable.Serializer {

        @Override
        protected void serializeValue(UsedLanguage value, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException {
            jgen.writeObject(new UsedLanguageUpdateAdapter.Wrapper(value));
        }
    }

    public static class Deserializer extends AbstractJsonIterable.Deserializer {

        @Override
        protected UsedLanguage deserializeValue(JsonNode node, DeserializationContext ctxt) throws IOException {
            if (node.isTextual()) {
                return UsedLanguage.of(node.asText());
            } else {
                UsedLanguageUpdateAdapter.Wrapper wrapper = ctxt.getParser().getCodec().treeToValue(node, UsedLanguageUpdateAdapter.Wrapper.class);
                return wrapper.getUsedLanguage();
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy