mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
使用抛出异常方式代替null
This commit is contained in:
@@ -311,7 +311,7 @@ public class EnumUtil {
|
|||||||
public static Map<String, Object> getNameFieldMap(final Class<? extends Enum<?>> clazz, final String fieldName) {
|
public static Map<String, Object> getNameFieldMap(final Class<? extends Enum<?>> clazz, final String fieldName) {
|
||||||
final Enum<?>[] enums = clazz.getEnumConstants();
|
final Enum<?>[] enums = clazz.getEnumConstants();
|
||||||
if (null == enums) {
|
if (null == enums) {
|
||||||
return Collections.emptyMap();
|
throw new IllegalArgumentException(StrUtil.format("Class [{}] is not an Enum type!", clazz.getName()));
|
||||||
}
|
}
|
||||||
final Map<String, Object> map = MapUtil.newHashMap(enums.length, true);
|
final Map<String, Object> map = MapUtil.newHashMap(enums.length, true);
|
||||||
for (final Enum<?> e : enums) {
|
for (final Enum<?> e : enums) {
|
||||||
|
Reference in New Issue
Block a user