Created
March 25, 2019 03:18
-
-
Save Xarrow/504b91d67a9eec961862b451b4824c7e to your computer and use it in GitHub Desktop.
公安标准民族映射
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Optional; | |
import java.util.stream.Stream; | |
public final class PsbEnum { | |
public static enum SexType { | |
MALE(1, "男"), | |
FEMALE(2, "女"), | |
UNKNOWN(9, "未说明"); | |
private Integer type; | |
private String chineseType; | |
SexType(Integer type, String chineseType) { | |
this.type = type; | |
this.chineseType = chineseType; | |
} | |
public String getChineseType() { | |
return chineseType; | |
} | |
SexType(Integer type) { | |
this.type = type; | |
} | |
public Integer getType() { | |
return type; | |
} | |
} | |
//根据GA 59.7-1993采集 | |
public static enum CertificateType { | |
IDENTITY_CARD(11), | |
RESIDENCE_CERTI(13), | |
MILITARY_CERTI(90), | |
POLICE_CERTI(91), | |
SOLDIER_CERTI(91), | |
PASSPORT(93), | |
OTHER(99); | |
private Integer type; | |
CertificateType(Integer type) { | |
this.type = type; | |
} | |
public Integer getType() { | |
return type; | |
} | |
} | |
public static enum NationEnum { | |
HA("HA", "汉族", "01"), | |
MG("MG", "蒙古族", "02"), | |
HU("HU", "回族", "03"), | |
ZA("ZA", "藏族", "04"), | |
UG("UG", "维吾尔", "05"), | |
MH("MH", "苗族", "06"), | |
YI("YI", "彝族", "07"), | |
ZH("ZH", "壮族", "08"), | |
BY("BY", "布依族", "09"), | |
CS("CS", "朝鲜族", "10"), | |
MA("MA", "满族", "11"), | |
DO("DO", "侗族", "12"), | |
YA("YA", "瑶族", "13"), | |
BA("BA", "白族", "14"), | |
TJ("TJ", "土家族", "15"), | |
HN("HN", "哈尼族", "16"), | |
KZ("KZ", "哈萨克", "17"), | |
DA("DA", "傣族", "18"), | |
LI("LI", "黎族", "19"), | |
LS("LS", "傈僳族", "20"), | |
VA("VA", "佤族", "21"), | |
SH("SH", "畲族", "22"), | |
GS("GS", "高山族", "23"), | |
LH("LH", "拉祜族", "24"), | |
SU("SU", "水族", "25"), | |
DX("DX", "东乡族", "26"), | |
NX("NX", "纳西族", "27"), | |
JP("JP", "景颇族", "28"), | |
KG("KG", "柯尔克", "29"), | |
TU("TU", "土族", "30"), | |
DU("DU", "达斡尔", "31"), | |
ML("ML", "么佬族", "32"), | |
QI("QI", "羌族", "33"), | |
BL("BL", "布朗族", "34"), | |
SL("SL", "拉萨族", "35"), | |
MN("MN", "毛南族", "36"), | |
GL("GL", "仡佬族", "37"), | |
XB("XB", "锡伯族", "38"), | |
AC("AC", "阿昌族", "39"), | |
PM("PM", "普米族", "40"), | |
TA("TA", "塔吉克", "41"), | |
NU("NU", "怒族", "42"), | |
UZ("UZ", "乌孜别", "43"), | |
RS("RS", "俄罗斯", "44"), | |
EW("EW", "鄂温克", "45"), | |
DE("DE", "德昂族", "46"), | |
BN("BN", "保安族", "47"), | |
YG("YG", "裕固族", "48"), | |
GI("GI", "京族", "49"), | |
TT("TT", "塔塔尔", "50"), | |
DR("DR", "独龙族", "51"), | |
OR("OR", "鄂伦春", "52"), | |
HZ("HZ", "赫哲族", "53"), | |
MB("MB", "门巴族", "54"), | |
LB("LB", "珞巴族", "55"), | |
JN("JN", "基诺族", "56"), | |
OTHER("OTHER", "其他", "99") | |
; | |
/** | |
* 代码 | |
*/ | |
private String code; | |
/** | |
* 名称 | |
*/ | |
private String name; | |
/** | |
* 国标 | |
*/ | |
private String ns; | |
NationEnum(String code, String name, String ns) { | |
this.code = code; | |
this.name = name; | |
this.ns = ns; | |
} | |
public String getCode() { | |
return code; | |
} | |
public String getName() { | |
return name; | |
} | |
public String getNs() { | |
return ns; | |
} | |
public static Optional<NationEnum> getByCode(final String code) { | |
return Stream.of(NationEnum.values()) | |
.filter(ne -> ne.getCode().equalsIgnoreCase(code)) | |
.findFirst(); | |
} | |
public static Optional<NationEnum> getByName(final String name) { | |
return Stream.of(NationEnum.values()) | |
.filter(ne -> ne.getName().contains(name)) | |
.findFirst(); | |
} | |
public static Optional<NationEnum> getByNs(final String ns) { | |
return Stream.of(NationEnum.values()) | |
.filter(ne -> ne.getNs().equalsIgnoreCase(ns)) | |
.findFirst(); | |
} | |
public static Optional<NationEnum> getByFoo(final String foo) { | |
Optional<NationEnum> en; | |
en = getByCode(foo); | |
if (en.isPresent()) { | |
return en; | |
} | |
en = getByName(foo); | |
if (en.isPresent()) { | |
return en; | |
} | |
en = getByNs(foo); | |
if (en.isPresent()) { | |
return en; | |
} | |
return en; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment