public class ComparatorHelper extends Object
The string expression should be in the form of comma-separated values, where each value represents the name of property whose value is used as input to the Comparator#compare(Object, Object) method and an optional order string ("asc" or "desc"). If not specified, ascending order will be assumed.
For example, the string name:asc,dateOfBirth:desc will create the following comparator chain:
new ChainedComparator(new Comparator[]
{
new ExtractorComparator(new ReflectionExtractor("getName")),
new InverseComparator(new ExtractorComparator(new ReflectionExtractor("getDateOfBirth")))
});
| Constructor and Description |
|---|
ComparatorHelper() |
| Modifier and Type | Method and Description |
|---|---|
static Comparator |
createComparator(String sExpr)
Create a new Comparator from the specified string.
|
public static Comparator createComparator(String sExpr)
sExpr - a string expression representing a Comparator. Contains
a list of property name/ordering pairs, separated by a
colon. For example: