- java.lang.Object
-
- org.omnifaces.utils.Comparators
-
public final class Comparators extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> Comparator<T>firstWhen(Predicate<? super T> predicate, Comparator<? super T> comparator)Create a newComparatorthat places values that match the givenPredicatebefore values that do not.static <T> Comparator<T>lastWhen(Predicate<? super T> predicate, Comparator<? super T> comparator)Create a newComparatorthat places values that match the givenPredicateafter values that do not.
-
-
-
Method Detail
-
firstWhen
public static <T> Comparator<T> firstWhen(Predicate<? super T> predicate, Comparator<? super T> comparator)
Create a newComparatorthat places values that match the givenPredicatebefore 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 newComparatorthat places values that match the givenPredicateafter 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
-
-