public enum AreaChineseTypes {
BJ("11", "北京"),
TJ("12", "天津"),
HeiBei("13", "河北"),
ShanXi("14", "山西"),
NMG("15", "内蒙"),
LL("21", "辽宁"),
DL("2102", "大连"),
JL("22", "吉林"),
HLJ("23", "黑龙江"),
SHS("31", "上海"),
JSS("32", "江苏"),
ZJS("33", "浙江"),
LBS("3302", "宁波"),
AH("34", "安徽"),
FJ("35", "福建"),
XM("3502", "厦门"),
JX("36", "江西"),
SD("37", "山东"),
QD("3702", "青岛"),
HNS("41", "河南"),
HuBei("42", "湖北"),
HN("43", "湖南"),
GD("44", "广东"),
SZ("4403", "深圳"),
GXZZ("45", "广西"),
HeiNan("46", "海南"),
CQ("50", "重庆"),
SC("51", "四川"),
GZ("52", "贵州"),
YN("53", "云南"),
XZ("54", "西藏"),
ShanXiShen("61", "陕西"),
GS("62", "甘肃"),
QH("63", "青海"),
LX("64", "宁夏"),
XJ("65", "新疆"),
AM("82", "澳门");
public static String matchByAreaCode(String areaCode) {
if (!StringUtils.hasText(areaCode)) {
return "空";
}
AreaChineseTypes areaChineseTypes = Arrays.stream(values()).filter(k -> k.areaCode.equals(areaCode)).findAny().orElse(null);
if (areaChineseTypes == null) {
return areaCode;
}
return areaChineseTypes.name;
}
private final String areaCode;
private final String name;
AreaChineseTypes(String areaCode, String name) {
this.areaCode = areaCode;
this.name = name;
}
public String getAreaCode() {
return areaCode;
}
public String getName() {
return name;
}
public static void main(String[] args) {
System.out.println(matchByAreaCode(""));
}
}
地区编码与中文对应枚举类
最新推荐文章于 2023-10-11 10:45:12 发布