public class CollectionSortFilter extends Object implements Filter
Filter that can sort a Collection or Map. A Collection is sorted using Collections.sort(List), and Maps
are sorted by inserting all items into a TreeMap. It is possible to
use comparators for certain classes; in order for those to be used, the
collection must return an object of a matching type as the first item of its
iterator. If comparators are not used, the sorted items have to implement the
Comparable interface or using this will filter will result in a
ClassCastException!| Constructor and Description |
|---|
CollectionSortFilter() |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
addComparator(Class<T> clazz,
Comparator<? super T> comparator)
Adds a comparator to use when an object of the given class is found as
first item in a collection’s iterator.
|
Object |
format(TemplateContext templateContext,
Object data,
Map<String,Object> parameters)
Formats the given data object.
|
public <T> void addComparator(Class<T> clazz, Comparator<? super T> comparator)
T - The type of the object to compareclazz - The class to use the comparator forcomparator - The comparator to useCopyright © 2026. All rights reserved.