Class ExpectedOrderSorter<T>

java.lang.Object
org.javimmutable.collections.common.ExpectedOrderSorter<T>

@NotThreadSafe public class ExpectedOrderSorter<T> extends Object
Class intended for use in unit tests to simplify sorting collections based on a standard ordering. The standard ordering comes from the order that values appear in an Iterator. During sorting process any values encountered in collection that did not appear in the Iterator trigger an IllegalArgumentException.
  • Constructor Details

    • ExpectedOrderSorter

      public ExpectedOrderSorter(Iterator<T> iterator)
  • Method Details

    • sort

      public <U, C extends Collection<U>> List<U> sort(@Nonnull C collection, @Nonnull java.util.function.Function<U,T> mapper)
      Creates a new List containing all of the elements of collection sorted based on the Iterator.
    • sort

      public <U> Iterator<U> sort(@Nonnull Iterator<U> iterator, @Nonnull java.util.function.Function<U,T> mapper)
      Creates a new List containing all of the elements of collection sorted based on the Iterator.