类 PropertyComparator<T>
- java.lang.Object
- org.springframework.beans.support.PropertyComparator<T>
- 所有已实现的接口:
Comparator<T>
public class PropertyComparator<T> extends Object implements Comparator<T>
PropertyComparator performs a comparison of two beans, evaluating the specified bean property via a BeanWrapper.- 从以下版本开始:
- 19.05.2003
- 作者:
- Juergen Hoeller, Jean-Pierre Pawlak
- 另请参阅:
BeanWrapper
构造器概要
构造器 构造器 说明 PropertyComparator(String property, boolean ignoreCase, boolean ascending)
Create a PropertyComparator for the given settings.PropertyComparator(SortDefinition sortDefinition)
Create a new PropertyComparator for the given SortDefinition.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 int
compare(T o1, T o2)
SortDefinition
getSortDefinition()
Return the SortDefinition that this comparator uses.static void
sort(Object[] source, SortDefinition sortDefinition)
Sort the given source according to the given sort definition.static void
sort(List<?> source, SortDefinition sortDefinition)
Sort the given List according to the given sort definition.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
构造器详细资料
PropertyComparator
public PropertyComparator(SortDefinition sortDefinition)
Create a new PropertyComparator for the given SortDefinition.
PropertyComparator
public PropertyComparator(String property, boolean ignoreCase, boolean ascending)
Create a PropertyComparator for the given settings.- 参数:
property
- the property to compareignoreCase
- whether upper and lower case in String values should be ignoredascending
- whether to sort ascending (true) or descending (false)
方法详细资料
getSortDefinition
public final SortDefinition getSortDefinition()
Return the SortDefinition that this comparator uses.
sort
public static void sort(List<?> source, SortDefinition sortDefinition) throws BeansException
Sort the given List according to the given sort definition.Note: Contained objects have to provide the given property in the form of a bean property, i.e. a getXXX method.
- 参数:
source
- the input ListsortDefinition
- the parameters to sort by- 抛出:
IllegalArgumentException
- in case of a missing propertyNameBeansException
sort
public static void sort(Object[] source, SortDefinition sortDefinition) throws BeansException
Sort the given source according to the given sort definition.Note: Contained objects have to provide the given property in the form of a bean property, i.e. a getXXX method.
- 参数:
source
- input sourcesortDefinition
- the parameters to sort by- 抛出:
IllegalArgumentException
- in case of a missing propertyNameBeansException