mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -248,6 +248,18 @@ public class EnumUtil {
|
|||||||
return Arrays.stream(implClass.getEnumConstants()).filter(e -> condition.apply(e).equals(value)).findAny().orElse(null);
|
return Arrays.stream(implClass.getEnumConstants()).filter(e -> condition.apply(e).equals(value)).findAny().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过 某字段对应值 获取 枚举,获取不到时为 {@code defaultEnum}
|
||||||
|
*
|
||||||
|
* @param condition 条件字段
|
||||||
|
* @param value 条件字段值
|
||||||
|
* @param defaultEnum 条件找不到则返回结果使用这个
|
||||||
|
* @return 对应枚举 ,获取不到时为 {@code null}
|
||||||
|
*/
|
||||||
|
public static <E extends Enum<E>, C> E getBy(final SerFunction<E, C> condition, final C value, final E defaultEnum) {
|
||||||
|
return ObjUtil.defaultIfNull(getBy(condition,value), defaultEnum);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 某字段对应值 获取 枚举中另一字段值,获取不到时为 {@code null}
|
* 通过 某字段对应值 获取 枚举中另一字段值,获取不到时为 {@code null}
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user