enum类型本质

public enum EnumRuleNid {
    
    PERCENT_AWARD("percent_award"), // 百分比奖励返给邀请人
    
    INVITE_AWARD("invite_award"), // 现金返给邀请人
    
    INVITER_AWARD("inviter_award"), // 现金返给被邀请人
    

    INDEX("index"), // 首页规则

    EnumRuleNid(String value) {
        this.value = value;
    }

    private String value;

    public String getValue() {
        return this.value;
    }    
}


enum本质就是普通java类,只不过是继承了Enum类。

 等价于:

public final class EnumRuleNid extends Enum
{

    private EnumRuleNid(String s, int i, String value)
    {
        super(s, i);
        this.value = value;
    }

    public String getValue()
    {
        return value;
    }

    public static EnumRuleNid[] values()
    {
        EnumRuleNid aenumrulenid[];
        int i;
        EnumRuleNid aenumrulenid1[];
        System.arraycopy(aenumrulenid = ENUM$VALUES, 0, aenumrulenid1 = new EnumRuleNid[i = aenumrulenid.length], 0, i);
        return aenumrulenid1;
    }

    public static EnumRuleNid valueOf(String s)
    {
        return (EnumRuleNid)Enum.valueOf(com/rd/common/enums/EnumRuleNid, s);
    }

    public static final EnumRuleNid PERCENT_AWARD;
    public static final EnumRuleNid INVITE_AWARD;
    public static final EnumRuleNid INVITER_AWARD;
    public static final EnumRuleNid INDEX;

   private String value;
    private static final EnumRuleNid ENUM$VALUES[];

    static
    {
        PERCENT_AWARD = new EnumRuleNid("PERCENT_AWARD", 0, "percent_award");
        INVITE_AWARD = new EnumRuleNid("INVITE_AWARD", 1, "invite_award");
        INVITER_AWARD = new EnumRuleNid("INVITER_AWARD", 2, "inviter_award");
        INDEX = new EnumRuleNid("INDEX", 3, "index");

        ENUM$VALUES = (new EnumRuleNid[] {
            PERCENT_AWARD, INVITE_AWARD, INVITER_AWARD, INDEX
        });
    }
}

你可能感兴趣的:(enum类型本质)