Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
use static import
Browse files Browse the repository at this point in the history
  • Loading branch information
venusdrogon committed Jun 8, 2017
1 parent 10a907f commit 7f6293d
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.feilong.core.util.comparator;

import static com.feilong.core.lang.ClassUtil.isInstance;

import java.io.Serializable;
import java.util.Comparator;
import java.util.TreeMap;
Expand All @@ -28,7 +30,6 @@

import com.feilong.core.bean.ConvertUtil;
import com.feilong.core.bean.PropertyUtil;
import com.feilong.core.lang.ClassUtil;

/**
* 属性比较器,自动获取 <code>T</code>中的属性名字是 {@link #propertyName}的值,进行比较,不用每个需要排序的字段创建 {@link Comparator}类.
Expand Down Expand Up @@ -448,9 +449,6 @@ private int compare(T t1,T t2,Comparable propertyValue1,Comparable propertyValue
@SuppressWarnings({ "rawtypes", "unchecked" })
private int compareWithSameValue(T t1,T t2){
//如果对象实现了 Comparable 接口, 那么直接强转比较
if (ClassUtil.isInstance(t1, Comparable.class)){
return ((Comparable) t1).compareTo(t2);
}
return 1;
return isInstance(t1, Comparable.class) ? ((Comparable) t1).compareTo(t2) : 1;
}
}

0 comments on commit 7f6293d

Please sign in to comment.