Java defines the enumeration class enum

public enum WsOrderStatusEnum {
    
    

	ORDER_STATUS_WAIT_PAY(0, "待支付"),

   ;



	private final Integer code;
	private final String info;

  
	WsOrderStatusEnum(Integer code, String info) {
    
    
		this.code = code;
		this.info = info;
	}

   //根据code获取value
	public static String getInfoByCode(Integer code) {
    
    
		if (null != code)
		{
    
    
			for (WsOrderStatusEnum value : values()) {
    
    
				if (value.getCode().equals(code)) {
    
    
					return value.getInfo();
				}
			}
		}
		return "未知";
	}

	public Integer getCode() {
    
    
		return code;
	}

	public String getInfo() {
    
    
		return info;
	}


}

Guess you like

Origin blog.csdn.net/qq_37741426/article/details/129851661