mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
ReflectUtil.getFieldsValue增加Filter重载
This commit is contained in:
parent
f245a721f6
commit
bb9736aba6
@ -2,12 +2,13 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.23(2023-09-28)
|
||||
# 5.8.23(2023-10-08)
|
||||
|
||||
### 🐣新特性
|
||||
* 【json 】 改进TemporalAccessorSerializer支持dayOfMonth和month枚举名(issue#I82AM8@Gitee)
|
||||
* 【core 】 新增ProxySocketFactory
|
||||
* 【http 】 UserAgent增加百度浏览器识别(issue#I847JY@Gitee)
|
||||
* 【core 】 ReflectUtil.getFieldsValue增加Filter重载(pr#1090@Gitee)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【cron 】 修复Cron表达式range解析错误问题(issue#I82CSH@Gitee)
|
||||
|
@ -187,7 +187,7 @@ public class ReflectUtil {
|
||||
* 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。
|
||||
*
|
||||
* @param beanClass 类
|
||||
* @param fieldFilter field过滤器,过滤掉不需要的field
|
||||
* @param fieldFilter field过滤器,过滤掉不需要的field,{@code null}返回原集合
|
||||
* @return 字段列表
|
||||
* @throws SecurityException 安全检查异常
|
||||
* @since 5.7.14
|
||||
@ -286,8 +286,20 @@ public class ReflectUtil {
|
||||
* @since 4.1.17
|
||||
*/
|
||||
public static Object[] getFieldsValue(Object obj) {
|
||||
return getFieldsValue(obj, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有字段的值
|
||||
*
|
||||
* @param obj bean对象,如果是static字段,此处为类class
|
||||
* @param filter 字段过滤器,,{@code null}返回原集合
|
||||
* @return 字段值数组
|
||||
* @since 5.8.23
|
||||
*/
|
||||
public static Object[] getFieldsValue(Object obj, Filter<Field> filter) {
|
||||
if (null != obj) {
|
||||
final Field[] fields = getFields(obj instanceof Class ? (Class<?>) obj : obj.getClass());
|
||||
final Field[] fields = getFields(obj instanceof Class ? (Class<?>) obj : obj.getClass(), filter);
|
||||
if (null != fields) {
|
||||
final Object[] values = new Object[fields.length];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user