All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class rebelsky.util.Assert

java.lang.Object
   |
   +----rebelsky.util.Assert

public class Assert
extends Object
A simple mechanism for asserting facts we expect to hold in order for methods to execute correctly. Most methods throw either rebelsky.util.FailedAssertion, rebelsky.util.FailedPostcondition, or rebelsky.util.FailedPrecondition. All of the methods are static, so you don't need to create an Assert object in order to call the methods. That is, you can just call Assert.pre(boolean,String), Assert.assert(boolean,String) and Assert.post(boolean,String).

Copyright (c) 1998 Samuel A. Rebelsky. All rights reserved.

Version:
1.0 of February 1998
Author:
Samuel A. Rebelsky

Constructor Index

o Assert()

Method Index

o assert(boolean, String)
Assert a condition with an explanation as to what went wrong if the condition failed.
o post(boolean, String)
Assert a postcondition with an explanation as to what went wrong if the postcondition failed.
o pre(boolean, String)
Assert a precondition with an explanation as to what went wrong if the precondition failed.

Constructors

o Assert
 public Assert()

Methods

o assert
 public static void assert(boolean condition,
                           String reason) throws FailedAssertion
Assert a condition with an explanation as to what went wrong if the condition failed.
pre: (none)
post: if the condition fails, an exception is thrown

Throws: FailedAssertion
when the condition fails
o post
 public static void post(boolean condition,
                         String reason) throws FailedPostcondition
Assert a postcondition with an explanation as to what went wrong if the postcondition failed.
pre: (none)
post: if the precondition fails, an exception is thrown

Throws: FailedPostcondition
when the precondition fails
o pre
 public static void pre(boolean condition,
                        String reason) throws FailedPrecondition
Assert a precondition with an explanation as to what went wrong if the precondition failed.
pre: (none), as we don't want to worry about recursively failed preconditions
post: if the precondition fails, an exception is thrown

Throws: FailedPrecondition
when the precondition fails

All Packages  Class Hierarchy  This Package  Previous  Next  Index