[Java]枚举类型:遍历为List Demo
llect.Lists;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public enum StandardOperationEntityType {
CREATE("CODELIST", "数据字典"),
DELETE("CODELIST_ITEM", "数据字典项");
private final String code;
private final String name;
StandardOperationEntityType(String code, String name){
this.name = name;
}
public static StandardOperationEntityType findByCode(String code) {
for (StandardOperationEntityType type : values()) {
if (Code().equals(code)) {
return type;
}
}
return null;
}
public static StandardOperationEntityType findByName(String name) {
for (StandardOperationEntityType type : values()) {
if (Name().equals(name)) {
return type;
}
}
return null;
}
public String getCode() {
nodejs字符串转数组de;
}
public String getName() {
return this.name;
}
public static List<Map<String, String>> toList() {
List<Map<String, String>> list = wArrayList();//wArrayList()其实和new ArrayList()⼏乎⼀模
for (StandardOperationEntityType item : StandardOperationEntityType.values()) {
Map<String, String> map = new HashMap<String, String>();
map.put("code", Code());
map.put("name", Name());
list.add(map);
}
return list;
}
}
X 参考⽂献

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。