info.javelot.functionalj.util
Class Utils

java.lang.Object
  extended byinfo.javelot.functionalj.util.Utils

public final class Utils
extends Object

Contains general utility methods.

Author:
Copyright © 2006 Frederic Daoud

Method Summary
static void disallowNull(Object p_parameter, String p_name)
          Verifies if the parameter is null, and throws an exception if it is.
static boolean safeEquals(Object p_first, Object p_second)
          Verifies if two objects are equal, by considering two null values to be equal, a null and non-null value not to be equal, and by using the equals() method to compare two non-null values.
static String toString(Object[] p_array)
          Returns a String representation of an array of objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

disallowNull

public static void disallowNull(Object p_parameter,
                                String p_name)
Verifies if the parameter is null, and throws an exception if it is. Does nothing if the parameter is not null.

Parameters:
p_parameter - the parameter that is checked for null.
p_name - the name of the parameter. This name will be displayed as part of the message of the FunctionException, if thrown, as follows: "The {name} parameter cannot be null."
Throws:
FunctionException - thrown if the parameter is null.

toString

public static String toString(Object[] p_array)
Returns a String representation of an array of objects.

Parameters:
p_array - the array for which to construct a String representation.
Returns:
a String of the form "[A, B, C, D]", with a String representation of each object in the array.

safeEquals

public static boolean safeEquals(Object p_first,
                                 Object p_second)
Verifies if two objects are equal, by considering two null values to be equal, a null and non-null value not to be equal, and by using the equals() method to compare two non-null values.

Parameters:
p_first - the first object to consider for equality.
p_second - the second object to consider for equality.
Returns:
true if the two objects are considered equal, false otherwise.