org.apache.hadoop.hbase.util
Class CollectionUtils

java.lang.Object
  extended by org.apache.hadoop.hbase.util.CollectionUtils

public class CollectionUtils
extends Object

Utility methods for dealing with Collections, including treating null collections as empty.


Constructor Summary
CollectionUtils()
           
 
Method Summary
static
<T> T
getFirst(Collection<T> collection)
          first/last
static
<T> T
getLast(List<T> list)
           
static int getLastIndex(List<?> list)
           
static
<T> boolean
isEmpty(Collection<T> collection)
          empty
static boolean isLastIndex(List<?> list, int index)
           
static
<T> boolean
notEmpty(Collection<T> collection)
           
static
<T> Collection<T>
nullSafe(Collection<T> in)
           
static
<A,B> boolean
nullSafeSameSize(Collection<A> a, Collection<B> b)
           
static
<T> int
nullSafeSize(Collection<T> collection)
          size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtils

public CollectionUtils()
Method Detail

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)


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.