EnumUtil use Linked

This commit is contained in:
Looly 2021-04-06 21:46:58 +08:00
parent 5b2ea8aec7
commit f05da040f0
2 changed files with 5 additions and 3 deletions

View File

@ -14,6 +14,7 @@
* 【core 】 增加港澳台电话正则pr#301@Gitee
* 【core 】 增加银行卡号脱敏pr#301@Gitee
* 【cache 】 使用LongAddr代替AtomicLongpr#301@Gitee
* 【cache 】 EnumUtil使用LinkedHashMappr#304@Gitee
### Bug修复
* 【core 】 修复Validator.isUrl()传空返回trueissue#I3ETTY@Gitee

View File

@ -1,13 +1,14 @@
package cn.hutool.core.util;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.map.MapUtil;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import cn.hutool.core.lang.Assert;
/**
* 枚举工具类
*
@ -239,7 +240,7 @@ public class EnumUtil {
if (null == enums) {
return null;
}
final Map<String, Object> map = new LinkedHashMap<>();
final Map<String, Object> map = MapUtil.newHashMap(enums.length, true);
for (Enum<?> e : enums) {
map.put(e.name(), ReflectUtil.getFieldValue(e, fieldName));
}