public enum PayServiceEnum { ALIPAY("ALIPAY","支付宝"), WECHAT("WECHAT","微信支付"), UNIONPAY("UNIONPAY","银联支付"); private String code; private String desc; public String getCode() { return code; } public String getDesc() { return desc; } PayServiceEnum(String code, String desc) { this.code = code; this.desc = desc; } public static PayServiceEnum getByCode(String code){ for (PayServiceEnum value : PayServiceEnum.values()) { if(value.getCode().equals(code)){ return value; } } return null; } }