Class CollectionUtils

java.lang.Object
com.mapr.org.apache.hadoop.hbase.util.CollectionUtils

public class CollectionUtils extends Object
Utility methods for dealing with Collections, including treating null collections as empty.
  • Constructor Details

    • CollectionUtils

      public CollectionUtils()
  • Method Details

    • nullSafe

      public static <T> Collection<T> nullSafe(Collection<T> in)
    • nullSafeSize

      public static <T> int nullSafeSize(Collection<T> collection)
      size
    • nullSafeSameSize

      public static <A, B> boolean nullSafeSameSize(Collection<A> a, Collection<B> b)
    • isEmpty

      public static <T> boolean isEmpty(Collection<T> collection)
      empty
    • notEmpty

      public static <T> boolean notEmpty(Collection<T> collection)
    • getFirst

      public static <T> T getFirst(Collection<T> collection)
      first/last
    • getLastIndex

      public static int getLastIndex(List<?> list)
      Parameters:
      list - any list
      Returns:
      -1 if list is empty, otherwise the max index
    • isLastIndex

      public static boolean isLastIndex(List<?> list, int index)
      Parameters:
      list -
      index - the index in question
      Returns:
      true if it is the last index or if list is empty and -1 is passed for the index param
    • getLast

      public static <T> T getLast(List<T> list)