public class CollectionUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
CollectionUtils.FilterExpression
Filter expression constructed by a string for use by
filter(Collection, FilterExpression, IFilterableValueDecorator)
. |
static interface |
CollectionUtils.IFilterableValueDecorator
Filter value decorator for use by
filter(Collection, FilterExpression, IFilterableValueDecorator) . |
static class |
CollectionUtils.RowValueBindingFilterableValueDecorator
Deprecated.
|
static class |
CollectionUtils.RowValueExpressionFilterableValueDecorator
Filter value decorator for table rows, using a binding expression to calculate the value.
|
static class |
CollectionUtils.SelectItemFilterableValueDecorator
Filter value decorator for
ISelectItemProvider s. |
Constructor and Description |
---|
CollectionUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
filter(Collection<?> collection,
CollectionUtils.FilterExpression filter,
CollectionUtils.IFilterableValueDecorator valueDecorator)
Removes the items from the specified collection whose value does not match the filter.
|
static void |
filter(Collection<?> collection,
String filter,
CollectionUtils.IFilterableValueDecorator valueDecorator)
Removes the items from the specified collection whose value does not match the filter.
|
static void |
sort(List<?> list,
boolean ascending)
Sorts the specified list by comparing the items in the list
using the
Comparable interface. |
static void |
sort(List<?> list,
ISortInfo sort,
String rowVariable)
Sorts the specified list using the specified
SortInfo . |
static void |
sort(List<?> list,
ValueBinding binding,
boolean ascending,
String rowVariable)
Deprecated.
use
sort(List, ValueExpression, boolean, String) instead |
static void |
sort(List<?> list,
ValueExpression binding,
boolean ascending,
String rowVariable)
Sorts the specified list using the specified
ValueBinding
to compare items in the list. |
public static void sort(List<?> list, boolean ascending)
Comparable
interface.
If items in the list are String
s, uses a locale-appropriate
Collator
for comparisons.list
- List to sort. Never null.ascending
- True to sort a-z/1-100/etc (natural order);
false to sort z-a/100-1/etc (reverse order).public static void sort(List<?> list, ISortInfo sort, String rowVariable)
SortInfo
.
The keys of the SortInfo
object should be
ValueBinding
objects which resolve to properties of the current list item.
When the ValueBinding
objects resolve to String
properties,
a locale-appropriate Collator
is used for comparisons;
otherwise the Comparable
interface is used.list
- List to sort. Never null.sort
- Sort-info to use to sort the list. The keys of this parameter
should be ValueExpression
objects which resolves to properties of the current list item.
For example, if the rowVariable is "item" and the sort-info has two keys,
the first of which is "#{item.foo}" and the second "#{item.bar}",
the list items will be compared first with the "foo" property of each item,
and then, where the "foo" item property value of two items is equal,
the "bar" property of each item.rowVariable
- Name of row variable used to represent the current list item
in the value-binding expression.@Deprecated public static void sort(List<?> list, ValueBinding binding, boolean ascending, String rowVariable)
sort(List, ValueExpression, boolean, String)
insteadValueBinding
to compare items in the list.
If the ValueBinding
resolves to a String
property,
uses a locale-appropriate Collator
for comparisons;
otherwise uses the Comparable
interface.list
- List to sort. Never null.binding
- Value-binding to use to compare items in a list.
For example, if the rowVariable is "item" and this value-binding is "#{item.foo}",
the list items will be compared using the "foo" property of each item.ascending
- True to sort a-z/1-100/etc (natural order);
false to sort z-a/100-1/etc (reverse order).rowVariable
- Name of row variable used to represent the current list item
in the value-binding expression.public static void sort(List<?> list, ValueExpression binding, boolean ascending, String rowVariable)
ValueBinding
to compare items in the list.
If the ValueBinding
resolves to a String
property,
uses a locale-appropriate Collator
for comparisons;
otherwise uses the Comparable
interface.list
- List to sort. Never null.binding
- Value-binding to use to compare items in a list.
For example, if the rowVariable is "item" and this value-binding is "#{item.foo}",
the list items will be compared using the "foo" property of each item.ascending
- True to sort a-z/1-100/etc (natural order);
false to sort z-a/100-1/etc (reverse order).rowVariable
- Name of row variable used to represent the current list item
in the value-binding expression.public static void filter(Collection<?> collection, String filter, CollectionUtils.IFilterableValueDecorator valueDecorator)
collection
- Items to filter. The collection will be iterated,
and the iterator's remove()
method will be called
for each item that does not match the filter.filter
- Expression to use to filter the collection.
The filter expression uses the standard commonsearch keyword rules
(* = wildcard, space = and, quotes = exact phrase).valueDecorator
- Decorator to use to calculate the value on which to filter
for each item in the collection.public static void filter(Collection<?> collection, CollectionUtils.FilterExpression filter, CollectionUtils.IFilterableValueDecorator valueDecorator)
collection
- Items to filter. The collection will be iterated,
and the iterator's remove()
method will be called
for each item that does not match the filter.filter
- Expression to use to filter the collection.
The filter expression uses the standard commonsearch keyword rules
(* = wildcard, space = and, quotes = exact phrase).valueDecorator
- Decorator to use to calculate the value on which to filter
for each item in the collection.