wt.util
Class Assert

java.lang.Object
  extended bywt.util.Assert
All Implemented Interfaces:
Serializable

public class Assert
extends Object
implements Serializable

Used for assertion checking. Every method prints a message to System.out if the assertion fails along with a stack trace to help pinpoint the class and line number in the source code where the assertion failed.

In general, things that are asserted using this class should be programming errors, because clients are not expected to know how to check for and handle failed assertions.

Supported API: false

Extendable: false

Since:
R4
See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
private static String COMPATIBLE_TYPE
           
private static String NON_EMPTY_ARRAY
           
private static String NON_NULL
           
private static String RESOURCE
           
 
Constructor Summary
Assert()
           
 
Method Summary
static boolean ASSERT(boolean condition, String message)
          Tests if a boolean condition is satisfied.
static boolean ASSERT(boolean condition, String pattern, Object[] inserts)
          Tests if a boolean condition is satisfied.
private static String getMessage(String msg, Object[] inserts)
          Formats a message with the given object inserts using java.text.MessageFormat.format.
private static String getStackTrace()
          generates a stack trace that shows the call stack with methods and line numbers.
static void main(String[] args)
          Used to test this class
static boolean NON_EMPTY_ARRAY(Object[] array)
          Tests if an array is empty.
static boolean NON_NULL(Object obj)
          Tests if an object is null.
static boolean TYPE_COMPATIBLE(Class a_class, Class type)
          Tests if two classes are type compatible with each other.
static boolean TYPE_COMPATIBLE(Object obj, Class type)
          Tests if an object's type is compatible with another type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

NON_NULL

private static final String NON_NULL
See Also:
Constant Field Values

NON_EMPTY_ARRAY

private static final String NON_EMPTY_ARRAY
See Also:
Constant Field Values

COMPATIBLE_TYPE

private static final String COMPATIBLE_TYPE
See Also:
Constant Field Values
Constructor Detail

Assert

public Assert()
Method Detail

ASSERT

public static boolean ASSERT(boolean condition,
                             String message)
Tests if a boolean condition is satisfied. If the condition is true then the method returns without taking any action, otherwise the message is printed to System.out.

Supported API: false

Parameters:
condition -
message -
Returns:
value of the condition parameter

ASSERT

public static boolean ASSERT(boolean condition,
                             String pattern,
                             Object[] inserts)
Tests if a boolean condition is satisfied. If the condition is true then the method returns without taking any action, otherwise the message is printed to System.out.

Supported API: false

Parameters:
condition -
pattern - Message with placeholders for object inserts (e.g. {0}) @see java.text.MessageFormat
inserts - objects that will be inserted into the message using java.text.MesageFormat.format @see java.text.MessageFormat
Returns:
value of the condition parameter

getStackTrace

private static String getStackTrace()
generates a stack trace that shows the call stack with methods and line numbers.

Returns:
String

getMessage

private static String getMessage(String msg,
                                 Object[] inserts)
Formats a message with the given object inserts using java.text.MessageFormat.format.

Parameters:
msg -
inserts -
Returns:
String

NON_NULL

public static boolean NON_NULL(Object obj)
Tests if an object is null. If so an IllegalArgumentException is thrown.

Supported API: false

Parameters:
obj - The object to test for null.
Returns:
true if the object is not null

NON_EMPTY_ARRAY

public static boolean NON_EMPTY_ARRAY(Object[] array)
Tests if an array is empty. If so an IllegalArgumentException is thrown.

Supported API: false

Parameters:
array -
Returns:
true if the array has at least one element

TYPE_COMPATIBLE

public static boolean TYPE_COMPATIBLE(Object obj,
                                      Class type)
Tests if an object's type is compatible with another type. If so an IllegalArgumentException is thrown.

Supported API: false

Parameters:
obj -
type - The type that the object is being checked against for compatability.
Returns:
true if the object can be successfully cast to the specified type

TYPE_COMPATIBLE

public static boolean TYPE_COMPATIBLE(Class a_class,
                                      Class type)
Tests if two classes are type compatible with each other. If so an IllegalArgumentException is thrown.

Supported API: false

Parameters:
a_class -
type - The type that the object is being checked against for compatability.
Returns:
true if the two classes are type compatible

main

public static void main(String[] args)
Used to test this class