org.jplate.foundation.util
Class Assert

java.lang.Object
  extended by org.jplate.foundation.util.Assert

public final class Assert
extends java.lang.Object

Provides validatation functionality through the concept of assertions: object not null, references not equal, non-empty string, etc.

The following are examples to perform assertions:

Modifications:
    $Date: 2008-12-02 12:32:45 -0500 (Tue, 02 Dec 2008) $
    $Revision: 479 $
    $Author: sfloess $
    $HeadURL: https://jplate.svn.sourceforge.net/svnroot/jplate/trunk/src/dev/java/org/jplate/foundation/util/Assert.java $
    


Constructor Summary
private Assert()
          Default constructor not allowed.
 
Method Summary
static void isOfClass(java.lang.Object toCheck, java.lang.Class klass)
          Ensures that toCheck is of class type klass.
static void isOfClass(java.lang.String msg, java.lang.Object toCheck, java.lang.Class klass)
          Ensures that toCheck is of class type klass.
static void isReferenced(java.lang.Object toCheck)
          Ensures that toCheck is referencing something other than null.
static void isReferenced(java.lang.String msg, java.lang.Object toCheck)
          Ensures that toCheck is referencing something other than null.
static void notEmptyString(java.lang.String toCheck)
          Ensures that toCheck is not empty or null.
static void notEmptyString(java.lang.String msg, java.lang.String toCheck)
          Ensures that toCheck is not empty or null.
static void notNull(java.lang.Object toCheck)
          Ensures that toCheck is not null.
static void notNull(java.lang.String msg, java.lang.Object toCheck)
          Ensures that toCheck is not null.
static void referenceNotEqual(java.lang.Object value1, java.lang.Object value2)
          Ensures that value1 and value2 are not equal.
static void referenceNotEqual(java.lang.String msg, java.lang.Object value1, java.lang.Object value2)
          Ensures that value1 and value2 are not equal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Assert

private Assert()
Default constructor not allowed.

Throws:
java.lang.UnsupportedOperationException - if this constructor is called.
Method Detail

notNull

public static void notNull(java.lang.String msg,
                           java.lang.Object toCheck)
                    throws java.lang.NullPointerException
Ensures that toCheck is not null. If it is, a NullPointerException is raised whose message is msg.

Parameters:
msg - The message to use in NullPointerException if toCheck is null.
toCheck - The object to check for null.
Throws:
java.lang.NullPointerException - If toCheck is null.

notNull

public static void notNull(java.lang.Object toCheck)
                    throws java.lang.NullPointerException
Ensures that toCheck is not null. If it is, a NullPointerException is raised.

Parameters:
toCheck - The object to check for null.
Throws:
java.lang.NullPointerException - If toCheck is null.

isReferenced

public static void isReferenced(java.lang.String msg,
                                java.lang.Object toCheck)
                         throws java.lang.IllegalArgumentException
Ensures that toCheck is referencing something other than null. If it is, a IllegalArgumentException is raised.

Parameters:
msg - The message to use in IllegalArgumentException if toCheck is null.
toCheck - The object to check for being a reference and not null.
Throws:
java.lang.IllegalArgumentException - If toCheck is null.

isReferenced

public static void isReferenced(java.lang.Object toCheck)
                         throws java.lang.IllegalArgumentException
Ensures that toCheck is referencing something other than null. If it is, a IllegalArgumentException is raised.

Parameters:
toCheck - The object to check for being a reference and not null.
Throws:
java.lang.IllegalArgumentException - If toCheck is null.

isOfClass

public static void isOfClass(java.lang.String msg,
                             java.lang.Object toCheck,
                             java.lang.Class klass)
                      throws java.lang.IllegalArgumentException
Ensures that toCheck is of class type klass. If not, an IllegalArgumentException is raised.

Parameters:
msg - The message to use in IllegalArgumentException if toCheck is not of class klass.
toCheck - The object to check for being of class type klass.
klass - The class that toCheck should be.
Throws:
java.lang.IllegalArgumentException - If toCheck's class is not klass.

isOfClass

public static void isOfClass(java.lang.Object toCheck,
                             java.lang.Class klass)
                      throws java.lang.IllegalArgumentException
Ensures that toCheck is of class type klass. If not, an IllegalArgumentException is raised.

Parameters:
toCheck - The object to check for being of class type klass.
klass - The class that toCheck should be.
Throws:
java.lang.IllegalArgumentException - If toCheck's class is not klass.

referenceNotEqual

public static void referenceNotEqual(java.lang.String msg,
                                     java.lang.Object value1,
                                     java.lang.Object value2)
                              throws java.lang.IllegalArgumentException
Ensures that value1 and value2 are not equal. If so, an IllegalArgumentException is raised whose message is msg.

Parameters:
msg - The message to use in IllegalArgumentException if toCheck is null.
value1 - The object to examine to ensure not equal to value2.
Throws:
java.lang.IllegalArgumentException - if toCheck is null.

referenceNotEqual

public static void referenceNotEqual(java.lang.Object value1,
                                     java.lang.Object value2)
                              throws java.lang.IllegalArgumentException
Ensures that value1 and value2 are not equal. If so, an IllegalArgumentException.

Parameters:
value1 - The object to examine to ensure not equal to value2.
Throws:
java.lang.IllegalArgumentException - if toCheck is null.

notEmptyString

public static void notEmptyString(java.lang.String msg,
                                  java.lang.String toCheck)
                           throws java.lang.IllegalArgumentException
Ensures that toCheck is not empty or null. If it is, an IllegalArgumentException is raised whose message is msg.

Parameters:
msg - The message to use in IllegalArgumentException if toCheck is null or empty.
toCheck - The string check for null or empty.
Throws:
java.lang.IllegalArgumentException - if toCheck is null or empty.

notEmptyString

public static void notEmptyString(java.lang.String toCheck)
                           throws java.lang.IllegalArgumentException
Ensures that toCheck is not empty or null. If it is, an IllegalArgumentException is raised.

Parameters:
toCheck - The string check for null or empty.
Throws:
java.lang.IllegalArgumentException - if toCheck is null or empty.