枚举类型的定义Enum

package com.erayt.pms.define;


public enum MarketType{

    REALTIME("0","RealTime","实时"),
    DAYEND("1","DayEnd","估值"),
    ;

    public String value;
    public String engName;
    public String chsName;

    private MarketType(String value, String engName, String chsName) {
        this.value = value;
        this.engName = engName;
        this.chsName = chsName;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getEngName() {
        return engName;
    }
    public void setEngName(String engName) {
        this.engName = engName;
    }
    public String getChsName() {
        return chsName;
    }
    public void setChsName(String chsName) {
        this.chsName = chsName;
    }
}

 

例二:


package com.erayt.system.sub.report.domain;


public enum PairsType {
	FX(0,"外汇"),
	FXC(1,"结售汇"),
	METAL(2,"贵金属"),
	GOODS(3,"商品"),
	UNKNOWN(9,"未知"),
	;
	
	public int val; //值
	public String txt; //描述
	
	private PairsType(int val,String txt){
		this.val = val;
		this.txt = txt;
	}
	
	public static PairsType valueOf(int val){
		for(PairsType pt:PairsType.values()){
			if(pt != null){
				if(pt.getVal() == val){
					return pt;
				}
			}
		}
		return PairsType.UNKNOWN;
	}

	public int getVal() {
		return val;
	}

	public String getTxt() {
		return txt;
	}

	public void setVal(int val) {
		this.val = val;
	}

	public void setTxt(String txt) {
		this.txt = txt;
	}
}

 

你可能感兴趣的:(自己的心得)