mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add propertiesFilter
This commit is contained in:
parent
3990516a31
commit
6d5ca7051b
@ -3,10 +3,11 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.6.2 (2021-03-18)
|
||||
# 5.6.2 (2021-03-19)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 Validator增加车架号(车辆识别码)验证、驾驶证(驾驶证档案编号)的正则校验(pr#280@Gitee)
|
||||
* 【core 】 CopyOptions增加propertiesFilter(pr#281@Gitee)
|
||||
### Bug修复
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
@ -188,7 +188,7 @@ public class BeanCopier<T> implements Copier<T>, Serializable {
|
||||
throw new BeanException(e, "Get value of [{}] error!", prop.getFieldName());
|
||||
}
|
||||
}
|
||||
if(!copyOptions.propertiesFilter.test(prop.getField(), value)) {
|
||||
if(null != copyOptions.propertiesFilter && false == copyOptions.propertiesFilter.test(prop.getField(), value)) {
|
||||
return;
|
||||
}
|
||||
if ((null == value && copyOptions.ignoreNullValue) || bean == value) {
|
||||
@ -248,9 +248,10 @@ public class BeanCopier<T> implements Copier<T>, Serializable {
|
||||
|
||||
// 获取属性值
|
||||
Object value = valueProvider.value(providerKey, fieldType);
|
||||
if(!copyOptions.propertiesFilter.test(prop.getField(), value)) {
|
||||
if(null != copyOptions.propertiesFilter && false == copyOptions.propertiesFilter.test(prop.getField(), value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((null == value && copyOptions.ignoreNullValue) || bean == value) {
|
||||
// 当允许跳过空时,跳过
|
||||
// 值不能为bean本身,防止循环引用
|
||||
|
@ -87,7 +87,6 @@ public class CopyOptions implements Serializable {
|
||||
* 构造拷贝选项
|
||||
*/
|
||||
public CopyOptions() {
|
||||
this.propertiesFilter = (f, v) -> true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -98,7 +97,7 @@ public class CopyOptions implements Serializable {
|
||||
* @param ignoreProperties 忽略的目标对象中属性列表,设置一个属性列表,不拷贝这些属性值
|
||||
*/
|
||||
public CopyOptions(Class<?> editable, boolean ignoreNullValue, String... ignoreProperties) {
|
||||
this();
|
||||
this.propertiesFilter = (f, v) -> true;
|
||||
this.editable = editable;
|
||||
this.ignoreNullValue = ignoreNullValue;
|
||||
this.ignoreProperties = ignoreProperties;
|
||||
|
Loading…
x
Reference in New Issue
Block a user