java.lang.Object
org.omnifaces.utils.Comparators
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Comparator<T>
firstWhen
(Predicate<? super T> predicate, Comparator<? super T> comparator) Create a newComparator
that places values that match the givenPredicate
before values that do not.static <T> Comparator<T>
lastWhen
(Predicate<? super T> predicate, Comparator<? super T> comparator) Create a newComparator
that places values that match the givenPredicate
after values that do not.
-
Method Details
-
firstWhen
public static <T> Comparator<T> firstWhen(Predicate<? super T> predicate, Comparator<? super T> comparator) Create a newComparator
that places values that match the givenPredicate
before values that do not. If either both values match the predicate or both do not match the predicate, the order is determined by the given comparator.- Type Parameters:
T
- the type of the values- Parameters:
predicate
- the predicate to use to sort the valuescomparator
- the comparator to use to sort any pairs of values that either both do or do not match the predicate- Returns:
- the new comparator
-
lastWhen
public static <T> Comparator<T> lastWhen(Predicate<? super T> predicate, Comparator<? super T> comparator) Create a newComparator
that places values that match the givenPredicate
after values that do not. If either both values match the predicate or both do not match the predicate, the order is determined by the given comparator.- Type Parameters:
T
- the type of the values- Parameters:
predicate
- the predicate to use to sort the valuescomparator
- the comparator to use to sort any pairs of values that either both do or do not match the predicate- Returns:
- the new comparator
-