|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.support.PropertyComparator
public class PropertyComparator
PropertyComparator performs a comparison of two beans, evaluating the specified bean property via a BeanWrapper.
BeanWrapper
Field Summary | |
---|---|
private BeanWrapperImpl |
beanWrapper
|
protected Log |
logger
|
private SortDefinition |
sortDefinition
|
Constructor Summary | |
---|---|
PropertyComparator(SortDefinition sortDefinition)
Create a new PropertyComparator for the given SortDefinition. |
|
PropertyComparator(java.lang.String property,
boolean ignoreCase,
boolean ascending)
Create a PropertyComparator for the given settings. |
Method Summary | |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
private java.lang.Object |
getPropertyValue(java.lang.Object obj)
Get the SortDefinition's property value for the given object. |
SortDefinition |
getSortDefinition()
Return the SortDefinition that this comparator uses. |
static void |
sort(java.util.List source,
SortDefinition sortDefinition)
Sort the given List according to the given sort definition. |
static void |
sort(java.lang.Object[] source,
SortDefinition sortDefinition)
Sort the given source according to the given sort definition. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
---|
equals |
Field Detail |
---|
protected final Log logger
private final SortDefinition sortDefinition
private final BeanWrapperImpl beanWrapper
Constructor Detail |
---|
public PropertyComparator(SortDefinition sortDefinition)
MutableSortDefinition
public PropertyComparator(java.lang.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)Method Detail |
---|
public final SortDefinition getSortDefinition()
public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
private java.lang.Object getPropertyValue(java.lang.Object obj)
obj
- the object to get the property value for
public static void sort(java.util.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 by
java.lang.IllegalArgumentException
- in case of a missing propertyName
BeansException
public static void sort(java.lang.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 by
java.lang.IllegalArgumentException
- in case of a missing propertyName
BeansException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |