public class BeanSorter extends Object
Sorts passed in Collections and returns sorted Lists. Performs sorting for any Class that has an associated Comparator implementation defined. If the Collection that is passed in, is not an instance of List, it will create a new ArrayList with the contents of the passed in Collection, before sorting occurs (since sorting can only be done on a java.util.List).
Constructor and Description |
---|
BeanSorter() |
Modifier and Type | Method and Description |
---|---|
static <T> List<T> |
sort(Collection<T> beans,
SortCriteria[] sortBy)
Sorts the passed in Collection and returns
a sorted List.
|
static <T> List<T> |
sort(Collection<T> beans,
String sortBy,
boolean nullsFirst)
Performs sorting of the collection by one property to
sort with more than one property see
sort(java.util.Collection, SortCriteria[]) . |
static <T> List<T> |
sort(Collection<T> beans,
String sortBy,
SortCriteria.Ordering ordering)
Performs sorting of the collection by one property to
sort with more than one property see
sort(java.util.Collection, SortCriteria[]) . |
static <T> List<T> |
sort(Collection<T> beans,
String sortBy,
SortCriteria.Ordering ordering,
boolean nullsFirst)
Performs sorting of the collection by one property to
sort with more than one property see
sort(java.util.Collection, SortCriteria[]) . |
public BeanSorter()
public static <T> List<T> sort(Collection<T> beans, String sortBy, SortCriteria.Ordering ordering)
sort(java.util.Collection, SortCriteria[])
.T
- Collection typebeans
- the Collection of PersistentObjects to sortsortBy
- the property to sort by (i.e. firstName, etc). Can
be a nested property such as 'person.address.street'.ordering
- the ordering of the sorting (either SortCriteria.Ordering.ASCENDING
or SortCriteria.Ordering.DESCENDING
)sort(java.util.Collection, SortCriteria[])
public static <T> List<T> sort(Collection<T> beans, String sortBy, boolean nullsFirst)
sort(java.util.Collection, SortCriteria[])
.T
- Collection typebeans
- the Collection of PersistentObjects to sortsortBy
- the property to sort by (i.e. firstName, etc). Can
be a nested property such as 'person.address.street'.nullsFirst
- a flag indicating whether or not null values should be sorted to the beginning
or the ending of the list.sort(java.util.Collection, SortCriteria[])
public static <T> List<T> sort(Collection<T> beans, String sortBy, SortCriteria.Ordering ordering, boolean nullsFirst)
sort(java.util.Collection, SortCriteria[])
.T
- Collection typebeans
- the Collection of PersistentObjects to sortsortBy
- the property to sort by (i.e. firstName, etc). Can
be a nested property such as 'person.address.street'.ordering
- the ordering of the sorting (either SortCriteria.Ordering.ASCENDING
or SortCriteria.Ordering.DESCENDING
)nullsFirst
- a flag indicating whether or not null values should be sorted to the beginning
or the ending of the list.sort(java.util.Collection, SortCriteria[])
public static <T> List<T> sort(Collection<T> beans, SortCriteria[] sortBy)
Sorts the passed in Collection and returns a sorted List. Performs SQL like sorting for any Class that has an associated Comparator implementation defined. If the Collection that is passed in, is not an instance of List, it will create a new ArrayList with the contents of the passed in Collection, before sorting occurs. Since sorting can only be done on a java.util.List. If it is a list, then in-line sorting will occur of the list.
T
- Collection typebeans
- the Collection of PersistentObjects to sortsortBy
- an array of SortCriteria. This array of SortCriteria
specifies which attributes to sort by.
Attributes to sort by, MUST be simple attributes
(i.e. name, type, etc, they can not be complex objects, but the properties can be
nested simple types within associated beans).Copyright © 2003–2014 AndroMDA.org. All rights reserved.