|
@@ -3,8 +3,6 @@ package com.diagbot.util;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
-import java.util.Collections;
|
|
|
|
-import java.util.Comparator;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -121,19 +119,16 @@ public class ReflectUtil {
|
|
*/
|
|
*/
|
|
public <T> void sort(List<T> tList, String property) {
|
|
public <T> void sort(List<T> tList, String property) {
|
|
if (ListUtil.isNotEmpty(tList) && tList.size() > 1) {
|
|
if (ListUtil.isNotEmpty(tList) && tList.size() > 1) {
|
|
- Collections.sort(tList, new Comparator<T>() {
|
|
|
|
- @Override
|
|
|
|
- public int compare(T o1, T o2) {
|
|
|
|
- String v1 = getProperty(o1, property);
|
|
|
|
- String v2 = getProperty(o2, property);
|
|
|
|
- if (StringUtil.isBlank(v1)) {
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- if (StringUtil.isBlank(v2)) {
|
|
|
|
- return 1;
|
|
|
|
- }
|
|
|
|
- return v1.compareTo(v2);
|
|
|
|
|
|
+ tList.sort((a, b) -> {
|
|
|
|
+ String v1 = getProperty(a, property);
|
|
|
|
+ String v2 = getProperty(b, property);
|
|
|
|
+ if (StringUtil.isBlank(v1)) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if (StringUtil.isBlank(v2)) {
|
|
|
|
+ return 1;
|
|
}
|
|
}
|
|
|
|
+ return v1.compareTo(v2);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|