T - the type of objects that may be compared by this comparatorpublic class PropertyComparator<T> extends Object implements Comparator<T>
BeanWrapper| Constructor and Description | 
|---|
| PropertyComparator(SortDefinition sortDefinition)Create a new PropertyComparator for the given SortDefinition. | 
| PropertyComparator(String property,
                  boolean ignoreCase,
                  boolean ascending)Create a PropertyComparator for the given settings. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | compare(T o1,
       T o2) | 
| SortDefinition | getSortDefinition()Return the SortDefinition that this comparator uses. | 
| static void | sort(List<?> source,
    SortDefinition sortDefinition)Sort the given List according to the given sort definition. | 
| static void | sort(Object[] source,
    SortDefinition sortDefinition)Sort the given source according to the given sort definition. | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongprotected final Log logger
public PropertyComparator(SortDefinition sortDefinition)
MutableSortDefinitionpublic PropertyComparator(String property, boolean ignoreCase, boolean ascending)
property - the property to compareignoreCase - whether upper and lower case in String values should be ignoredascending - whether to sort ascending (true) or descending (false)public final SortDefinition getSortDefinition()
public int compare(T o1, T o2)
compare in interface Comparator<T>public static void sort(List<?> source, SortDefinition sortDefinition) throws BeansException
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 byIllegalArgumentException - in case of a missing propertyNameBeansExceptionpublic static void sort(Object[] source, SortDefinition sortDefinition) throws BeansException
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 byIllegalArgumentException - in case of a missing propertyNameBeansException