!1 NullComparator 比较器bug修复

* 1. 当使用 new PropertyComparator("endTime", false) 时,把null值放到最后,不生效
This commit is contained in:
想长大的笨小孩 2023-03-25 10:00:44 +00:00
parent 9b81e5502d
commit 3c13da5515
2 changed files with 1 additions and 6 deletions

View File

@ -53,7 +53,7 @@ public class FuncComparator<T> extends NullComparator<T> {
*/
@SuppressWarnings({"rawtypes", "unchecked"})
private int compare(T o1, T o2, Comparable v1, Comparable v2) {
int result = ObjectUtil.compare(v1, v2);
int result = ObjectUtil.compare(v1, v2, this.nullGreater);
if (0 == result) {
//避免TreeSet / TreeMap 过滤掉排序字段相同但是对象不相同的情况
result = CompareUtil.compare(o1, o2, this.nullGreater);

View File

@ -51,11 +51,6 @@ public class NullComparator<T> implements Comparator<T>, Serializable {
return new NullComparator<>(nullGreater, comparator == null ? other : comparator.thenComparing(other));
}
@Override
public Comparator<T> reversed() {
return new NullComparator<>((false == nullGreater), comparator == null ? null : comparator.reversed());
}
/**
* 不检查{@code null}的比较方法<br>
* 用户可自行重写此方法自定义比较方式