home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / ccs_util.jar / com / commerceone / util / contract / Contract.class (.txt) next >
Encoding:
Java Class File  |  1999-12-09  |  1.5 KB  |  44 lines

  1. package com.commerceone.util.contract;
  2.  
  3. public class Contract {
  4.    public static final boolean REQUIRE = true;
  5.    public static final boolean ENSURE = true;
  6.    public static final boolean CHECK = true;
  7.  
  8.    public static void require(boolean expr) throws ProgrammerError {
  9.       if (!expr) {
  10.          throw new ProgrammerError("REQUIRE");
  11.       }
  12.    }
  13.  
  14.    public static void require(boolean expr, String msg) throws ProgrammerError {
  15.       if (!expr) {
  16.          throw new ProgrammerError("REQUIRE: " + msg);
  17.       }
  18.    }
  19.  
  20.    public static void ensure(boolean expr) throws ProgrammerError {
  21.       if (!expr) {
  22.          throw new ProgrammerError("ENSURE");
  23.       }
  24.    }
  25.  
  26.    public static void ensure(boolean expr, String msg) throws ProgrammerError {
  27.       if (!expr) {
  28.          throw new ProgrammerError("ENSURE:" + msg);
  29.       }
  30.    }
  31.  
  32.    public static void check(boolean expr) throws ProgrammerError {
  33.       if (!expr) {
  34.          throw new ProgrammerError("CHECK");
  35.       }
  36.    }
  37.  
  38.    public static void check(boolean expr, String msg) throws ProgrammerError {
  39.       if (!expr) {
  40.          throw new ProgrammerError("CHECK: " + msg);
  41.       }
  42.    }
  43. }
  44.