
org.meeuw.i18n.languages.jaxb.LanguageCodeAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of i18n-iso-639 Show documentation
Show all versions of i18n-iso-639 Show documentation
Provides a class with one instance of every of the ISO 639 languages
package org.meeuw.i18n.languages.jaxb;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import org.meeuw.i18n.languages.LanguageCode;
public class LanguageCodeAdapter extends XmlAdapter {
@Override
public LanguageCode unmarshal(String v) throws Exception {
if (v == null || v.isEmpty()) {
return null;
}
return LanguageCode.get(v).orElseThrow(() -> new IllegalStateException("No such language " + v));
}
@Override
public String marshal(LanguageCode v) throws Exception {
if (v == null) {
return null;
}
return v.getCode();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy