zl程序教程

您现在的位置是:首页 >  其它

当前栏目

自定义枚举类型

类型 自定义 枚举
2023-09-27 14:24:54 时间

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum EnumPartyRole{
	


	
	SYSTEM("SYSTEM","XX平台"),
	SYSTEM_ADMIN("SYSTEM_ADMIN","XX平台-超级管理员"),
	SYSTEM_OPERATION("SYSTEM_OPERATION","XX平台-运营");

	
	
	private final String code;
	private final String description;

	private static final Map<String,EnumPartyRole> lookup = new HashMap<String,EnumPartyRole>();

	static {
		for (EnumPartyRole s : EnumSet.allOf(EnumPartyRole.class)) {
			lookup.put(s.getCode(), s);
		}
	}
		
	
	public static EnumPartyRole get(String code) {
		if(code!=null){code = code.trim();}
		return lookup.get(code);
	}
	
	EnumPartyRole(String code,String description) {
		this.code = code;
		this.description = description;
	}

	public String getCode() {
		return code;
	}

	public String getDescription() {
		return description;
	}
}