public enum PayStatusEnum { PAY_INIT(0,"待支付"), PAY_SUCCESS(1,"已支付"), PAY_FILED(2,"支付失败"); private Integer code; private String name; PayStatusEnum(Integer code, String name) { this.code = code; this.name = name; } public static PayStatusEnum getEnum(Integer code){ for(PayStatusEnum type: PayStatusEnum.values()){ if(code==type.getCode()){ return type; } } return null; } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public String getName() { return name; } public void setName(String name) { this.name = name; }}