com.basilv.core
Class Assert

java.lang.Object
  extended by com.basilv.core.Assert

public class Assert
extends Object

Provides assertion support. A failed assertion will throw an AssertionError.

The methods are generally of the form: methodXXX(message, expression). If the expression fails the assertion, then the AssertionException is created using the specified message and then thrown.


Constructor Summary
Assert()
           
 
Method Summary
static void greaterThanZero(int evalInt)
          Fails the assertion if the integer is not greater than zero.
static void greaterThanZero(String intDescription, int evalInt)
          Fails the assertion if the integer is not greater than zero.
static void isFalse(boolean expression)
          Fails the assertion if the specified expression is true.
static void isFalse(String expressionDescription, boolean expression)
          Fails the assertion if the specified expression is true.
static void isTrue(boolean expression)
          Fails the assertion if the specified expression is false.
static void isTrue(String expressionDescription, boolean expression)
          Fails the assertion if the specified expression is false.
static void notNegative(int evalInt)
          Fails the assertion if the integer is less than zero.
static void notNegative(String intDescription, int evalInt)
          Fails the assertion if the integer is less than zero.
static void notNull(Object evalObj)
          Fails the assertion if the specified object is null.
static void notNull(String objDescription, Object evalObj)
          Fails the assertion if the specified object is null.
static void notNullOrEmpty(String evalString)
          Fails the assertion if the specified string is null or empty.
static void notNullOrEmpty(String stringDescription, String evalString)
          Fails the assertion if the specified string is null or empty.
static void shouldNotReach()
          Automatically throws an AssertionException.
static void shouldNotReach(String message)
          Automatically throws an AssertionException using the specified message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Assert

public Assert()
Method Detail

isTrue

public static void isTrue(String expressionDescription,
                          boolean expression)
Fails the assertion if the specified expression is false.


isTrue

public static void isTrue(boolean expression)
Fails the assertion if the specified expression is false.


isFalse

public static void isFalse(String expressionDescription,
                           boolean expression)
Fails the assertion if the specified expression is true.


isFalse

public static void isFalse(boolean expression)
Fails the assertion if the specified expression is true.


notNull

public static void notNull(Object evalObj)
Fails the assertion if the specified object is null.


notNull

public static void notNull(String objDescription,
                           Object evalObj)
Fails the assertion if the specified object is null.


notNullOrEmpty

public static void notNullOrEmpty(String evalString)
Fails the assertion if the specified string is null or empty.


notNullOrEmpty

public static void notNullOrEmpty(String stringDescription,
                                  String evalString)
Fails the assertion if the specified string is null or empty.

Parameters:
stringDescription - A description of the string being evaluated.
evalString - The string to evaluate.

notNegative

public static void notNegative(int evalInt)
Fails the assertion if the integer is less than zero.

Parameters:
evalInt - The integer to evaluate.

notNegative

public static void notNegative(String intDescription,
                               int evalInt)
Fails the assertion if the integer is less than zero.

Parameters:
intDescription - A description of the integer being evaluated.
evalInt - The integer to evaluate.

greaterThanZero

public static void greaterThanZero(int evalInt)
Fails the assertion if the integer is not greater than zero.

Parameters:
evalInt - The integer to evaluate.

greaterThanZero

public static void greaterThanZero(String intDescription,
                                   int evalInt)
Fails the assertion if the integer is not greater than zero.

Parameters:
intDescription - A description of the integer being evaluated.
evalInt - The integer to evaluate.

shouldNotReach

public static void shouldNotReach()
Automatically throws an AssertionException.


shouldNotReach

public static void shouldNotReach(String message)
Automatically throws an AssertionException using the specified message.



EnvGen available from www.basilv.com/psd/software Copyright © 2007 Basil Vandegriend. All Rights Reserved.