com.calitha.util
Class Util

java.lang.Object
  extended by com.calitha.util.Util

public final class Util
extends Object

The Util class provides several convenience methods making application development easier.

Author:
Robert van Loenhout

Constructor Summary
Util()
           
 
Method Summary
static
<T> void
addArrayToCollection(Collection<T> collection, T[] array)
          Adds all elements of an array to a collection
static
<T> T[]
appendArrays(T[] array1, T[] array2, Class<T> cls)
          Appends two arrays together.
static Boolean equalsNoState(Object first, Object second)
          Determines if two objects are equal.
static
<T> T[]
listToArray(List<T> list, Class<T> cls)
          Copies a list to an Object array.
static void printArray(PrintStream stream, Object[] array)
          Copies an array to a print stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

printArray

public static void printArray(PrintStream stream,
                              Object[] array)
Copies an array to a print stream.

Parameters:
stream - stream
array - array
Throws:
IllegalArgumentException - if an argument is null

appendArrays

public static <T> T[] appendArrays(T[] array1,
                                   T[] array2,
                                   Class<T> cls)
Appends two arrays together.

Parameters:
array1 - first array
array2 - second array
cls - class of the objects in the array
Returns:
new array
Throws:
IllegalArgumentException - if an argument is null

addArrayToCollection

public static <T> void addArrayToCollection(Collection<T> collection,
                                            T[] array)
Adds all elements of an array to a collection

Parameters:
collection - collection
array - array
Throws:
IllegalArgumentException - if an argument is null

listToArray

public static <T> T[] listToArray(List<T> list,
                                  Class<T> cls)
Copies a list to an Object array.

Parameters:
list - list that is used as input
cls - class of the objects in the list
Returns:
new object array
Throws:
IllegalArgumentException - if an argument is null

equalsNoState

public static Boolean equalsNoState(Object first,
                                    Object second)
Determines if two objects are equal.

The state is not taken into account if two objects are equal, and therefore this method can return null to signal that the internal state must be compared too before it can be determined if the objects are equal.

This method is useful as the first step in the equals method of objects.

Parameters:
first - first object
second - second object
Returns:
true if it is equal, false if is unequal, null if more tests are needed.