nl.vpro.domain.media.bind.CountryCodeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of media-domain Show documentation
Show all versions of media-domain Show documentation
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.
package nl.vpro.domain.media.bind;
import java.util.Optional;
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import org.meeuw.i18n.regions.Region;
/**
* @author Michiel Meeuwissen
* @since 3.0
*/
public class CountryCodeAdapter extends XmlAdapter {
@Override
public Region unmarshal(CountryWrapper countryWrapper) {
return Optional.ofNullable(countryWrapper)
.map(CountryWrapper::getCode)
.orElse(null);
}
@Override
public CountryWrapper marshal(Region v) {
return Optional.ofNullable(v)
.map(CountryWrapper::new)
.orElse(null);
}
}