org.biojava.utils.contract
Class Contract

java.lang.Object
  |
  +--org.biojava.utils.contract.Contract

public final class Contract
extends java.lang.Object

Some minimal support for "design by contract" with pre-conditions, post-conditions and integrity rules (assertions).

Author:
Gerald Loeffler

Method Summary
static void assert(boolean condition, java.lang.String msg)
          check if a condition is met and throw an exception if not.
static void post(boolean condition, java.lang.String msg)
          check if postcondition is met and throw an exception if not.
static void pre(boolean condition, java.lang.String msg)
          check if precondition is met and throw an exception if not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pre

public static void pre(boolean condition,
                       java.lang.String msg)
check if precondition is met and throw an exception if not.
Parameters:
condition - the precondition that must be met
msg - if the condition is not met (i.e. is not true) an object of class PreconditionNotMetException (which is a sub-class of java.lang.IllegalArgumentException) is thrown with the message "A precondition was not met: " + msg + ".".
Throws:
PreconditionNotMetException - if condition is not true

post

public static void post(boolean condition,
                        java.lang.String msg)
check if postcondition is met and throw an exception if not.
Parameters:
condition - the postcondition that must be met
msg - if the condition is not met (i.e. is not true) an object of class PostconditionNotMetException (which is a sub-class of java.lang.RuntimeException) is thrown with the message "A postcondition was not met: " + msg + ".".
Throws:
PostconditionNotMetException - if condition is not true

assert

public static void assert(boolean condition,
                          java.lang.String msg)
check if a condition is met and throw an exception if not.
Parameters:
condition - the condition that must be met
msg - if the condition is not met (i.e. is not true) an object of class AssertionFailedException (which is a sub-class of java.lang.RuntimeException) is thrown with the message "An assertion failed: " + msg + ".".
Throws:
AssertionFailedException - if condition is not true