mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:20:07 +08:00
PropertyComparator增加compareSelf构造重载
This commit is contained in:
parent
829fecdc38
commit
1dab5a70fc
@ -2,7 +2,7 @@
|
||||
# 🚀Changelog
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
# 5.8.28(2024-05-08)
|
||||
# 5.8.28(2024-05-09)
|
||||
|
||||
### 🐣新特性
|
||||
* 【core 】 修正XmlUtil的omitXmlDeclaration描述注释(issue#I9CPC7@Gitee)
|
||||
@ -16,6 +16,7 @@
|
||||
* 【captcha】 HttpDownloader.downloadBytes增加超时参数重载(issue#3556@Github)
|
||||
* 【http 】 增加ExceptionFilter和DefaultExceptionFilter支持异常处理(issue#3568@Github)
|
||||
* 【poi 】 增加ExcelWriter.addIgnoredErrors,支持忽略警告小标
|
||||
* 【core 】 PropertyComparator增加compareSelf构造重载(issue#3569@Github)
|
||||
|
||||
### 🐞Bug修复
|
||||
* 【http 】 修复HttpUtil.urlWithFormUrlEncoded方法重复编码问题(issue#3536@Github)
|
||||
|
@ -6,9 +6,8 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
* Bean属性排序器<br>
|
||||
* 支持读取Bean多层次下的属性
|
||||
*
|
||||
* @author Looly
|
||||
*
|
||||
* @param <T> 被比较的Bean
|
||||
* @author Looly
|
||||
*/
|
||||
public class PropertyComparator<T> extends FuncComparator<T> {
|
||||
private static final long serialVersionUID = 9157326766723846313L;
|
||||
@ -25,10 +24,23 @@ public class PropertyComparator<T> extends FuncComparator<T> {
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param property 属性名
|
||||
* @param property 属性名
|
||||
* @param isNullGreater null值是否排在后(从小到大排序)
|
||||
*/
|
||||
public PropertyComparator(String property, boolean isNullGreater) {
|
||||
super(isNullGreater, (bean)-> BeanUtil.getProperty(bean, property));
|
||||
this(property, true, isNullGreater);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param property 属性名
|
||||
* @param compareSelf 在字段值相同情况下,是否比较对象本身。
|
||||
* 如果此项为{@code false},字段值比较后为0会导致对象被认为相同,可能导致被去重。
|
||||
* @param isNullGreater null值是否排在后(从小到大排序)
|
||||
* @since 5.8.28
|
||||
*/
|
||||
public PropertyComparator(String property, final boolean compareSelf, boolean isNullGreater) {
|
||||
super(isNullGreater, compareSelf, (bean) -> BeanUtil.getProperty(bean, property));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user