java枚举类型使用举例

源代码:

package com.jzfq.rms.autoApprove.enums;

/**
 * @author 大连桔子分期科技有限公司
 * @description 风控处理结果枚举
 * @date 20171207  1146
 */
public enum FKDealEnum {

    Theorderispending(0, "订单挂起"),
    Directlyrejected(1, "直接拒绝"),
    Refuselater(2, "稍后拒绝"),
    Jumpout(3, "直接跳出"),
    Jumpoutlater(4, "稍后跳出"),
    Directlabor(5, "直接人工"),
    Laterartificial(6, "稍后人工"),
    Passdirectly(7, "直接通过"),
    Passlater(8, "稍后通过"),
    Theprocesscontinues(9, "流程继续"),
    NOTINTYPE(10,"非内部规则不予处理"),
    RuleException(11,"未命中")
            ;

    private Integer code;
    private String name;

    FKDealEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    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;
    }

    public static String getName(Integer code) {
        for (FKDealEnum c : FKDealEnum.values()) {
            if (c.getCode() == code) {
                return c.getName();
            }
        }
        return null;
    }
}



使用:

//取值

FKDealEnum.NOTINTYPE.getCode()
//取键
 
  
FKDealEnum.getName(Integer code);

你可能感兴趣的:(java后端,spring)