org.meeuw.i18n.FormerlyAssignedCountryCode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of i18n-formerly-assigned Show documentation
Show all versions of i18n-formerly-assigned Show documentation
Provides an enum with ISO 3166-3 codes
package org.meeuw.i18n;
import java.time.Year;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import com.google.common.collect.Range;
/**
* This class is automaticly generated from https://en.wikipedia.org/wiki/ISO_3166-3 It defines all known ISO 3166-3 codes for former countries
*
*/
public enum FormerlyAssignedCountryCode {
BQAQ("British Antarctic Territory", null, Arrays.asList("BQ", "ATB"), Range.closed(Year.of(1974), Year.of(1979))),
BUMM("Burma", null, Arrays.asList("BU", "BUR", "104"), Range.closed(Year.of(1974), Year.of(1989))),
BYAA("Byelorussian SSR", null, Arrays.asList("BY", "BYS", "112"), Range.closed(Year.of(1974), Year.of(1992))),
CTKI("Canton and Enderbury Islands", null, Arrays.asList("CT", "CTE", "128"), Range.closed(Year.of(1974), Year.of(1984))),
CSHH("Czechoslovakia", null, Arrays.asList("CS", "CSK", "200"), Range.closed(Year.of(1974), Year.of(1993))),
DYBJ("Dahomey", null, Arrays.asList("DY", "DHY", "204"), Range.closed(Year.of(1974), Year.of(1977))),
NQAQ("Dronning Maud Land", null, Arrays.asList("NQ", "ATN", "216"), Range.closed(Year.of(1974), Year.of(1983))),
TPTL("East Timor", null, Arrays.asList("TP", "TMP", "626"), Range.closed(Year.of(1974), Year.of(2002))),
FXFR("France, Metropolitan", null, Arrays.asList("FX", "FXX", "249"), Range.closed(Year.of(1993), Year.of(1997))),
AIDJ("French Afars and Issas", null, Arrays.asList("AI", "AFI", "262"), Range.closed(Year.of(1974), Year.of(1977))),
FQHH("French Southern and Antarctic Territories", null, Arrays.asList("FQ", "ATF"), Range.closed(Year.of(1974), Year.of(1979))),
DDDE("German Democratic Republic", null, Arrays.asList("DD", "DDR", "278"), Range.closed(Year.of(1974), Year.of(1990))),
GEHH("Gilbert and Ellice Islands", null, Arrays.asList("GE", "GEL", "296"), Range.closed(Year.of(1974), Year.of(1979))),
JTUM("Johnston Island", null, Arrays.asList("JT", "JTN", "396"), Range.closed(Year.of(1974), Year.of(1986))),
MIUM("Midway Islands", null, Arrays.asList("MI", "MID", "488"), Range.closed(Year.of(1974), Year.of(1986))),
ANHH("Netherlands Antilles", null, Arrays.asList("AN", "ANT", "530"), Range.closed(Year.of(1974), Year.of(2010))),
NTHH("Neutral Zone", null, Arrays.asList("NT", "NTZ", "536"), Range.closed(Year.of(1974), Year.of(1993))),
NHVU("New Hebrides", null, Arrays.asList("NH", "NHB", "548"), Range.closed(Year.of(1974), Year.of(1980))),
PCHH("Pacific Islands (Trust Territory)", null, Arrays.asList("PC", "PCI", "582"), Range.closed(Year.of(1974), Year.of(1986))),
PZPA("Panama Canal Zone", null, Arrays.asList("PZ", "PCZ"), Range.closed(Year.of(1974), Year.of(1980))),
CSXX("Serbia and Montenegro", null, Arrays.asList("CS", "SCG", "891"), Range.closed(Year.of(2003), Year.of(2006))),
SKIN("Sikkim", null, Arrays.asList("SK", "SKM"), Range.closed(Year.of(1974), Year.of(1975))),
RHZW("Southern Rhodesia", null, Arrays.asList("RH", "RHO", "716"), Range.closed(Year.of(1974), Year.of(1980))),
PUUM("United States Miscellaneous Pacific Islands", null, Arrays.asList("PU", "PUS", "849"), Range.closed(Year.of(1974), Year.of(1986))),
HVBF("Upper Volta", null, Arrays.asList("HV", "HVO", "854"), Range.closed(Year.of(1974), Year.of(1984))),
SUHH("USSR", null, Arrays.asList("SU", "SUN", "810"), Range.closed(Year.of(1974), Year.of(1992))),
VDVN("Viet-Nam, Democratic Republic of", null, Arrays.asList("VD", "VDR"), Range.closed(Year.of(1974), Year.of(1977))),
WKUM("Wake Island", null, Arrays.asList("WK", "WAK", "872"), Range.closed(Year.of(1974), Year.of(1986))),
YDYE("Yemen, Democratic", null, Arrays.asList("YD", "YMD", "720"), Range.closed(Year.of(1974), Year.of(1990))),
YUCS("Yugoslavia", null, Arrays.asList("YU", "YUG", "891"), Range.closed(Year.of(1974), Year.of(2003))),
ZRCD("Zaire", null, Arrays.asList("ZR", "ZAR", "180"), Range.closed(Year.of(1974), Year.of(1997)));
private final String nameInEnglish;
private final Locale locale;
private final List formerCodes;
private final Range validity;
private FormerlyAssignedCountryCode(String name, Locale locale, List formerCodes, Range validity) {
this.nameInEnglish = name;
this.locale = locale;
this.formerCodes = formerCodes;
this.validity = validity;
}
/**
* Returns the name of this region (in english)
*
*/
public String getName() {
return nameInEnglish;
}
/**
* Returns the locale associated with this country. This may not always be possible, but many countries are associated with a language, and other locale specific settings
*
*/
public Locale toLocale() {
return locale;
}
/**
* Returns the ISO 3166-3 code for this formal country
*
*/
public String getISO3166_3_Code() {
return (name());
}
/**
* Returns a list of all official codes this country used to have
*
*/
public List getFormerCodes() {
return formerCodes;
}
public Range getValidity() {
return validity;
}
/**
* Gets by the former country by its 4 letter code. It will also try to match by the original 2 codes. This may not be unique, and then the most recently assigned one will match
*
*/
public static FormerlyAssignedCountryCode getByCode(String code) {
for (FormerlyAssignedCountryCode proposal : values()) {
if(proposal.name().equals(code)) {
return proposal;
}
}
Year until = Year.of(1);
FormerlyAssignedCountryCode proposal = null;
for (FormerlyAssignedCountryCode v : values()) {
for (String formerCode : v.getFormerCodes()) {
if(formerCode.equals(code) & v.getValidity().upperEndpoint().isAfter(until)) {
proposal = v;
}
}
}
return proposal;
}
}