org.shept.beans.support
public class PropertyComparator extends Object implements Comparator
getPropertyValue(Object) method to support Tuples also.BeanWrapper| Modifier and Type | Class and Description |
|---|---|
private static class |
PropertyComparator.WrappedProperty |
| Modifier and Type | Field and Description |
|---|---|
private org.springframework.beans.BeanWrapperImpl |
beanWrapper |
protected org.apache.commons.logging.Log |
logger |
private org.springframework.beans.support.SortDefinition |
sortDefinition |
| Constructor and Description |
|---|
PropertyComparator(org.springframework.beans.support.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(Object o1,
Object o2) |
private Object |
getPropertyValue(Object obj)
Get the SortDefinition's property value for the given object.
|
org.springframework.beans.support.SortDefinition |
getSortDefinition()
Return the SortDefinition that this comparator uses.
|
static void |
sort(List source,
org.springframework.beans.support.SortDefinition sortDefinition)
Sort the given List according to the given sort definition.
|
static void |
sort(Object[] source,
org.springframework.beans.support.SortDefinition sortDefinition)
Sort the given source according to the given sort definition.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitequalsprotected final org.apache.commons.logging.Log logger
private final org.springframework.beans.support.SortDefinition sortDefinition
private final org.springframework.beans.BeanWrapperImpl beanWrapper
public PropertyComparator(org.springframework.beans.support.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 org.springframework.beans.support.SortDefinition getSortDefinition()
public int compare(Object o1, Object o2)
compare in interface Comparatorprivate Object getPropertyValue(Object obj)
obj - the object to get the property value forpublic static void sort(List source, org.springframework.beans.support.SortDefinition sortDefinition) throws org.springframework.beans.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 propertyNameorg.springframework.beans.BeansExceptionpublic static void sort(Object[] source, org.springframework.beans.support.SortDefinition sortDefinition) throws org.springframework.beans.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 propertyNameorg.springframework.beans.BeansExceptionCopyright © 2014. All Rights Reserved.