mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-07 14:18:05 +08:00
!964 NullComparator 比较器bug修复
Merge pull request !964 from 想长大的笨小孩/v5-master
This commit is contained in:
commit
953fc7b18f
@ -53,7 +53,7 @@ public class FuncComparator<T> extends NullComparator<T> {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
private int compare(T o1, T o2, Comparable v1, Comparable v2) {
|
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) {
|
if (0 == result) {
|
||||||
//避免TreeSet / TreeMap 过滤掉排序字段相同但是对象不相同的情况
|
//避免TreeSet / TreeMap 过滤掉排序字段相同但是对象不相同的情况
|
||||||
result = CompareUtil.compare(o1, o2, this.nullGreater);
|
result = CompareUtil.compare(o1, o2, this.nullGreater);
|
||||||
|
@ -51,11 +51,6 @@ public class NullComparator<T> implements Comparator<T>, Serializable {
|
|||||||
return new NullComparator<>(nullGreater, comparator == null ? other : comparator.thenComparing(other));
|
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>
|
* 不检查{@code null}的比较方法<br>
|
||||||
* 用户可自行重写此方法自定义比较方式
|
* 用户可自行重写此方法自定义比较方式
|
||||||
|
Loading…
Reference in New Issue
Block a user