枚举的用法

package com.hd.ec.common.utils.status;

public enum HdOrderStatusEnum {

    YJD(500,"已建单"),DSH(11,"待审核"), DFP(12,"待分配"), DFYG(21,"待分员工"), TH(33,"退回"), DCL(
            24,"待处理"), CX(296,"撤销"), CLZ(26,"处理中"), CJ(1,"成交"), WCJ(
            3,"未成交"), GB(4,"关闭"),YCL(27,"已处理"),DQR(520,"待确认");

    private HdOrderStatusEnum(int id,String name) {
        this.id = id;
        this.name =name;
    }

    private int id;
    private String name;

    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public static String getName(int id) {  
        for (HdOrderStatusEnum c : HdOrderStatusEnum.values()) {  
            if (c.getId() == id) {  
                return c.name;  
            }  
        }  
        return null;  
    }  

}
用时, 类名点出

 

posted @ 2015-10-13 16:00  LEON.LEE  阅读(201)  评论(0编辑  收藏  举报