-
/** * */ package com.***.enums; /** * 根据发票代码查找发票所属省份 * * @author jinyulinlang date:2018年7月26日 */ public enum CityEnum { BJS("北京市", "11"), SHHS("上海市", "31"), TJS("天津市", "12"), CHQS("重庆市", "50"), XGTBXZQ("香港特别行政区", "xg"), AMTBXZQ( "澳门特别行政区", "am"), HEBS("河北省", "13"), ZJS("浙江省", "33"), LNS("辽宁省", "21"), HUBS("湖北省", "42"), JSS("江苏省", "32"), NMGZZQ("内蒙古自治区", "15"), JXS("江西省", "36"), SXS("山西省", "14"), GSS("甘肃省", "62"), SDS("山东省", "37"), HLJS("黑龙江省", "23"), FJS("福建省", "35"), GDS("广东省", "44"), SCS("四川省", "52"), HUNS("湖南省", "43"), HENS("河南省", "41"), YNS("云南省", "53"), AHS("安徽省", "34"), NXZZQ("宁夏回族自治区", "64"), JLS("吉林省", "22"), GXZZQ("广西壮族自治区", "45"), GZS("贵州省", "52"), SHXS("陕西省", "61"), QHS("青海省", "63"), HINS("海南省", "46"), XZ("西藏自治区", "54"), XJZZQ("新疆维吾尔自治区", "65"); private String name; private String index; /** * 构造器 * * @param name * @param index */ private CityEnum(String name, String index) { this.name = name; this.index = index; } public static String getName(String index) { for (CityEnum city : CityEnum.values()) { if (city.index.equals(index)) { return city.name; } } return "本系统暂不支持港澳台发票相关业务!"; } /** * 测试 * * @param args */ public static void main(String[] args) { String name2 = getName("41"); System.out.println(name2); } } /** * */ package com.*****.test; import com.sun.glass.ui.TouchInputSupport; /** * @Title: TestEnum.java * @author jinyulinlang * @date 2018年9月27日 * @version V1.0 */ public enum TestEnum { NONE("NoPadding"), ISO10126("ISO10126Padding"), OAEP("OAEPPadding"), OAEPWithMd5AndMgf1( "OAEPWithMD5AndMGF1Padding"), OAEPWithSha1AndMgf1("OAEPWithSHA-1AndMGF1Padding"), OAEPWithSha256AndMgf1( "OAEPWithSHA-256AndMGF1Padding"), OAEPWithSha384AndMgf1( "OAEPWithSHA-384AndMGF1Padding"), OAEPWithSha512AndMgf1( "OAEPWithSHA-512AndMGF1Padding"), PKCS1( "PKCS1Padding"), PKCS5("PKCS5Padding"), SSL3("SSL3Padding"); private String name; private TestEnum(String name) { this.name = name; } public String getname() { return this.name; } public static TestEnum getName(String name) { for (TestEnum testEnum : TestEnum.values()) { if (testEnum.name.equals(name)) { return testEnum; } } return null; } public static void main(String[] args) { TestEnum name2 = getName("OAEPPadding"); System.out.println(name2); } }
关于枚举类的两种用法
最新推荐文章于 2024-09-23 21:55:07 发布