https://www.cnblogs.com/c-Ajing/p/13448335.html
/** * java枚举类转List
更简单一点的方法
Listlist = Stream.of(EnergyConsumption.values()) .sorted(Comparator.comparing(EnergyConsumption::getType)) .map(item -> new JSONObject(new LinkedHashMap<>()) .fluentPut("type", item.getType()) .fluentPut("name", item.getName()) .fluentPut("chName", item.getChName()) ) .collect(Collectors.toList());
还没有评论,来说两句吧...