mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add propertiesFilter
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user