Class Comparators

java.lang.Object
org.omnifaces.utils.Comparators

public final class Comparators extends Object
  • Method Details

    • firstWhen

      public static <T> Comparator<T> firstWhen(Predicate<? super T> predicate, Comparator<? super T> comparator)
      Create a new Comparator that places values that match the given Predicate 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 values
      comparator - 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 new Comparator that places values that match the given Predicate 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 values
      comparator - the comparator to use to sort any pairs of values that either both do or do not match the predicate
      Returns:
      the new comparator