List of usage examples for org.springframework.beans.support PropertyComparator PropertyComparator
public PropertyComparator(SortDefinition sortDefinition)
From source file:org.springframework.beans.support.PropertyComparator.java
/** * Sort the given List according to the given sort definition. * <p>Note: Contained objects have to provide the given property * in the form of a bean property, i.e. a getXXX method. * @param source the input List/*w w w .j a v a 2s. c o m*/ * @param sortDefinition the parameters to sort by * @throws java.lang.IllegalArgumentException in case of a missing propertyName */ public static void sort(List<?> source, SortDefinition sortDefinition) throws BeansException { if (StringUtils.hasText(sortDefinition.getProperty())) { Collections.sort(source, new PropertyComparator<>(sortDefinition)); } }
From source file:org.springframework.beans.support.PropertyComparator.java
/** * Sort the given source according to the given sort definition. * <p>Note: Contained objects have to provide the given property * in the form of a bean property, i.e. a getXXX method. * @param source input source// w w w. jav a 2s.c o m * @param sortDefinition the parameters to sort by * @throws java.lang.IllegalArgumentException in case of a missing propertyName */ public static void sort(Object[] source, SortDefinition sortDefinition) throws BeansException { if (StringUtils.hasText(sortDefinition.getProperty())) { Arrays.sort(source, new PropertyComparator<>(sortDefinition)); } }