public class

PropertyComparator

extends Object
implements Comparator<T>
java.lang.Object
   ↳ org.springframework.beans.support.PropertyComparator

Class Overview

PropertyComparator performs a comparison of two beans, evaluating the specified bean property via a BeanWrapper.

See Also

Summary

Fields
protected final Log logger
Public Constructors
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.
Public Methods
int compare(Object o1, Object o2)
final 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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.util.Comparator

Fields

protected final Log logger

Also: SpringBeans

Public Constructors

public PropertyComparator (SortDefinition sortDefinition)

Also: SpringBeans

Create a new PropertyComparator for the given SortDefinition.

public PropertyComparator (String property, boolean ignoreCase, boolean ascending)

Also: SpringBeans

Create a PropertyComparator for the given settings.

Parameters
property the property to compare
ignoreCase whether upper and lower case in String values should be ignored
ascending whether to sort ascending (true) or descending (false)

Public Methods

public int compare (Object o1, Object o2)

Also: SpringBeans

public final SortDefinition getSortDefinition ()

Also: SpringBeans

Return the SortDefinition that this comparator uses.

public static void sort (Object[] source, SortDefinition sortDefinition)

Also: SpringBeans

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.

Parameters
source input source
sortDefinition the parameters to sort by
Throws
IllegalArgumentException in case of a missing propertyName
BeansException

public static void sort (List source, SortDefinition sortDefinition)

Also: SpringBeans

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.

Parameters
source the input List
sortDefinition the parameters to sort by
Throws
IllegalArgumentException in case of a missing propertyName
BeansException