org.erights.e.develop.assertion
Class T

java.lang.Object
  |
  +--org.erights.e.develop.assertion.T

public class T
extends Object

Untamed: This class provides assert and require checks you can add to your program.

If the the checks fail, unchecked exceptions of class RuntimeException are thrown.

Once E can commit to Java 1.4, then calls to static assertion methods of this class (the 'test' methods) should be converted to the new Java 1.4 "assert" syntax, in which case they can be switched off, or possibly stripped from the code. Therefore, the meaning of a program should be insensitive to whether an assertion check (a 'test') is performed.

Calls to static 'require' methods of this class are non-optional -- they are considered part of the program, and may not be removed.

History: Brian Marick wrote the original as the class 'Assertion', designed to work with his unassert utility, which was unfortunately not open sourced with the rest of E. Now that Java 1.4 will be providing us an alternative mechanism before we can expect to revive this, Mark Miller removed the stripping support mechanism, while also renaming 'Assertion' to 'T', and duplicated 'test' as 'require' in order to have both kinds of check. Most previous users of 'test' have been moved to 'require', as it wasn't clear whether the test was optional for them.

Author:
Brian Marick, Mark Miller

Constructor Summary
T()
          Enabled:
 
Method Summary
static void fail()
          Enabled: If this method is executed, it throws a RuntimeException with the message "Failed: 'Unreachable' code was reached." Plant such assertions in places the program should never reach (such as the default case in a switch).
static void fail(String explanation)
          Enabled: If this method is executed, it throws a RuntimeException with the given explanation, prefixed by "Failed: ".
static void nonNull(Object specimen)
          Enabled: Requires that the specimen not be null
static void noop()
          Enabled: Does nothing.
static void require(boolean mustBeTrue, Object explanation0, Object explanation1)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4, Object explanation5)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4, Object explanation5, Object explanation6)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4, Object explanation5, Object explanation6, Object explanation7)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void require(boolean mustBeTrue, String explanation)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation, prefixed by "Failed: ".
static void requireSI(boolean mustBeTrue, Object explanation0, int explanation1)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue)
          Enabled: If the argument is false, throws a RuntimeException with the message "Failed: Assertion failed."
static void test(boolean mustBeTrue, Object explanation0, Object explanation1)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4, Object explanation5)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4, Object explanation5, Object explanation6)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, Object explanation0, Object explanation1, Object explanation2, Object explanation3, Object explanation4, Object explanation5, Object explanation6, Object explanation7)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
static void test(boolean mustBeTrue, String explanation)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation, prefixed by "Failed: ".
static void testSI(boolean mustBeTrue, Object explanation0, int explanation1)
          Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

T

public T()
Enabled:

Method Detail

noop

public static void noop()
Enabled: Does nothing.

Exists so other code can call this in order to give a programmer a convenient place (the call site) at which to place a breakpoint.


fail

public static void fail()
Enabled: If this method is executed, it throws a RuntimeException with the message "Failed: 'Unreachable' code was reached." Plant such assertions in places the program should never reach (such as the default case in a switch).


fail

public static void fail(String explanation)
Enabled: If this method is executed, it throws a RuntimeException with the given explanation, prefixed by "Failed: ".

Must errors thrown by the E implementation go though this point, so if you're running E in a Java debugger, this is a great place to put a breakpoint.


test

public static void test(boolean mustBeTrue)
Enabled: If the argument is false, throws a RuntimeException with the message "Failed: Assertion failed."


test

public static void test(boolean mustBeTrue,
                        String explanation)
Enabled: If the argument is false, throws a RuntimeException with the given explanation, prefixed by "Failed: ".


testSI

public static void testSI(boolean mustBeTrue,
                          Object explanation0,
                          int explanation1)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1,
                        Object explanation2)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1,
                        Object explanation2,
                        Object explanation3)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1,
                        Object explanation2,
                        Object explanation3,
                        Object explanation4)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1,
                        Object explanation2,
                        Object explanation3,
                        Object explanation4,
                        Object explanation5)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1,
                        Object explanation2,
                        Object explanation3,
                        Object explanation4,
                        Object explanation5,
                        Object explanation6)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


test

public static void test(boolean mustBeTrue,
                        Object explanation0,
                        Object explanation1,
                        Object explanation2,
                        Object explanation3,
                        Object explanation4,
                        Object explanation5,
                        Object explanation6,
                        Object explanation7)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           String explanation)
Enabled: If the argument is false, throws a RuntimeException with the given explanation, prefixed by "Failed: ".


requireSI

public static void requireSI(boolean mustBeTrue,
                             Object explanation0,
                             int explanation1)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1,
                           Object explanation2)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1,
                           Object explanation2,
                           Object explanation3)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1,
                           Object explanation2,
                           Object explanation3,
                           Object explanation4)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1,
                           Object explanation2,
                           Object explanation3,
                           Object explanation4,
                           Object explanation5)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1,
                           Object explanation2,
                           Object explanation3,
                           Object explanation4,
                           Object explanation5,
                           Object explanation6)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


require

public static void require(boolean mustBeTrue,
                           Object explanation0,
                           Object explanation1,
                           Object explanation2,
                           Object explanation3,
                           Object explanation4,
                           Object explanation5,
                           Object explanation6,
                           Object explanation7)
Enabled: If the argument is false, throws a RuntimeException with the given explanation arguments, concatenated as strings and prefixed by "Failed: ".

Use this routine when you need to avoid paying the overhead of string concatenation ("+") on every test. It does the concatenation only if the test fails.


nonNull

public static void nonNull(Object specimen)
Enabled: Requires that the specimen not be null

Parameters:
specimen -


comments?