Class ListUtils

java.lang.Object
org.aksw.commons.util.list.ListUtils

public class ListUtils extends Object
  • Constructor Details

    • ListUtils

      public ListUtils()
  • Method Details

    • getOrNull

      public static <T> T getOrNull(List<T> list, int i)
      Return the item at index or null if it does not exist. Checks the size of the list before accessing the item (hence, the complexity of size() is ideally O(1)) Argument must not be negative
      Parameters:
      list -
      i -
      Returns:
    • getOrDefault

      public static <T> T getOrDefault(List<T> list, int i, T dflt)
    • lastOrNull

      public static <T> T lastOrNull(List<T> list)
      Returns the last item of the list or null if it does not exist
    • lastOrDefault

      public static <T> T lastOrDefault(List<T> list, T defaultValue)