de.aitools.aq.check
Class A

java.lang.Object
  extended by de.aitools.aq.check.A

public final class A
extends java.lang.Object

This class implements a condition checking facility.

Whenever a programmer is certain that, at a particular point in a method, a condition must hold he can use the methods provided by this class to perform literally A.CHECK of the condition. If the condition evaluates to false this class throws a CheckFailedError, thus relieving the programmer of building custom exceptions or errors himself. The stack trace of a thrown error suffices to debug the failed program, but if necessary an additional error message may be supplied.

Examples:
A.CHECK_NOT_NULL(collection);
A.CHECK(collection.contains(key));
A.CHECK(sim >= 0 && sim <= 1, "Similarity value exceeds interval [0, 1].");

Note that Java implements its own assertion facility which can be used to do the very same, however, it is turned off by default on VM startup. Only an additional VM argument (e.g. -ea) turns the assertion facility on. This is too big a hurdle for it to be useful in everyday coding. If the Java assertion facility happens to be turned on by default at some point in the future one may replace all condition checks done by this class with assertion checks.

Note further that neither this condition checker nor Java's assertion facility should be used as a replacement for unit tests. Also, don't check conditions that require expensive computations since the overall runtime of your program may be harmed.

Version:
aitools 2.0, created on 05.12.2008 $Id: A.java,v 1.1 2011/02/15 10:32:35 hoppe Exp $
Author:
martin.potthast@medien.uni-weimar.de

Constructor Summary
A()
           
 
Method Summary
static void CHECK_NOT_NULL(java.lang.Object... objects)
           
static void CHECK_NOT_NULL(java.lang.Object object)
           
static void CHECK(boolean... conditions)
           
static void CHECK(boolean condition)
           
static void CHECK(boolean condition, java.lang.String message)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

A

public A()
Method Detail

CHECK

public static final void CHECK(boolean condition)

CHECK

public static final void CHECK(boolean... conditions)

CHECK

public static final void CHECK(boolean condition,
                               java.lang.String message)

CHECK_NOT_NULL

public static final void CHECK_NOT_NULL(java.lang.Object object)

CHECK_NOT_NULL

public static final void CHECK_NOT_NULL(java.lang.Object... objects)