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

nl.vpro.domain.media.bind.UsedLanguageAdapter 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.bind;


import java.util.Locale;

import jakarta.xml.bind.annotation.*;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import nl.vpro.domain.Xmlns;
import nl.vpro.domain.media.UsedLanguage;
import nl.vpro.domain.media.update.MediaUpdate;
import nl.vpro.i18n.Locales;
import nl.vpro.xml.bind.LocaleAdapter;

/**
 * Representation of a {@link UsedLanguage} for normal mediaobject. This includes the name of the language (in dutch) as {@link XmlValue}.
 * @author Michiel Meeuwissen
 * @since 8.2
 */
public class UsedLanguageAdapter extends XmlAdapter {


    @Override
    public UsedLanguage unmarshal(Wrapper v) {
        return v.getUsedLanguage();
    }

    @Override
    public Wrapper marshal(UsedLanguage v) {
        return new Wrapper(v);
    }


    /**
     * Used in {@link MediaUpdate}, which has a slightly different representation of {@link UsedLanguage}  * @author Michiel Meeuwissen
     * @since 8.2
     */
    @XmlAccessorType(XmlAccessType.NONE)
    @XmlType(name = "languageType",
        propOrder = {""},
        namespace = Xmlns.MEDIA_NAMESPACE
    )
    @JsonPropertyOrder(
        {"code", "usage", "value"}
    )
    public static class Wrapper extends UsedLanguage.AbstractWrapper {

        public Wrapper() {
        }

        public Wrapper(UsedLanguage language) {
            super(language);
        }

        @XmlValue
        @JsonProperty
        public String getValue() {
            return getCode().getDisplayLanguage(Locales.DUTCH);
        }

        public void setValue(String ignored) {
            // jaxb
        }

        @Override
        @XmlAttribute
        @XmlJavaTypeAdapter(LocaleAdapter.class)
        @JsonProperty("code")
        public Locale getCode() {
            return super.getCode();
        }



    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy