public static class Expressive.Comparators extends Object
Provides common implementations of comparators.
To promote reusability and reduce code clutter, this class provides implementations of comparators that are commonly used in code.
| Modifier and Type | Method and Description |
|---|---|
static <T> Comparator<T> |
all(Comparator<T>... comparators)
Returns a comparator which compares using the given comparators.
|
static <T> Comparator<T> |
all(Iterable<Comparator<T>> comparators)
Returns a comparator which compares using the given comparators.
|
static <T extends Comparable<T>> |
as(Class<T> comparable)
Returns a comparator for a given type that implements
Comparable |
static Comparator<String> |
caseInsensitive()
Returns a string comparator which ignores case.
|
static <T> ComparatorBuilder<T> |
compare(Class<T> type)
Returns a
ComparatorBuilder which allows the creation of a comparator for the given type based on the values
of bean properties on that object. |
static <T> Comparator<T> |
nullSafe(Comparator<T> delegate)
Returns a comparator that can safely compare null values.
|
static <T> Comparator<T> |
nullSafe(Comparator<T> delegate,
boolean nullLast)
Returns a comparator that can safely compare null values.
|
public static <T> ComparatorBuilder<T> compare(Class<T> type)
ComparatorBuilder which allows the creation of a comparator for the given type based on the values
of bean properties on that object.type - the type for which a comparator is being builtComparator to be createdComparatorBuilderpublic static <T> Comparator<T> nullSafe(Comparator<T> delegate)
delegate - Comparator.compare(Object, Object) on null valuesnullSafe(Comparator, boolean)public static <T> Comparator<T> nullSafe(Comparator<T> delegate, boolean nullLast)
delegate - nullLast - if true, null values are considered 'greater than' non-null, if false null values are 'less than'Comparator.compare(Object, Object) on null valuespublic static Comparator<String> caseInsensitive()
public static <T extends Comparable<T>> Comparator<T> as(Class<T> comparable)
Comparablecomparable - the type of the Comparable classpublic static <T> Comparator<T> all(Comparator<T>... comparators)
comparators - public static <T> Comparator<T> all(Iterable<Comparator<T>> comparators)
comparators - Copyright © 2013 Atomic Leopard. All Rights Reserved.