Class Breaker

java.lang.Object
etithespirit.orimod.util.collection.Breaker

public final class Breaker extends Object
  • Method Details

    • breakApart

      public static <T> List<T>[] breakApart(List<T> list, T around, int includeAroundIn) throws NullPointerException, IllegalArgumentException
      Breaks the given list in half at the given element (around). If includeAroundIn is -1, the element `around` will be discarded. If includeAroundIn is 0, it will be included in the first half. If includeAroundIn is 1, it will be included in the second half. If it is anything else, IllegalArgumentException will be raised.
      Type Parameters:
      T - The type of the list.
      Parameters:
      list - The list to split.
      around - The element to split around.
      includeAroundIn - -1 to remove around from both result lists, 0 to include it in the first list, or 1 to include it in the second list.
      Returns:
      Two lists that represent the contents of the input list.
      Throws:
      NullPointerException - If around is not part of list.
      IllegalArgumentException - If includeAroundIn is not -1, 0, or 1.