01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package EDU.purdue.cs.bloat.util;
22:
23: /**
24: * Mechanism for making assertions about things in BLOAT. If an assertion fails,
25: * an <tt>IllegalArgumentException</tt> is thrown.
26: */
27: public abstract class Assert {
28: public static void isTrue(boolean test, final String msg) {
29: if (!test) {
30: throw new IllegalArgumentException("Assert.isTrue: " + msg);
31: }
32: }
33:
34: public static void isFalse(final boolean test, final String msg) {
35: if (test) {
36: throw new IllegalArgumentException("Assert.isFalse: " + msg);
37: }
38: }
39:
40: public static void isNotNull(final Object test, final String msg) {
41: if (test == null) {
42: throw new IllegalArgumentException("Assert.isNotNull: "
43: + msg);
44: }
45: }
46:
47: public static void isNull(final Object test, final String msg) {
48: if (test != null) {
49: throw new IllegalArgumentException("Assert.isNull: " + msg);
50: }
51: }
52:
53: public static void isTrue(boolean test) {
54: if (!test) {
55: throw new IllegalArgumentException("Assert.isTrue failed");
56: }
57: }
58:
59: public static void isFalse(final boolean test) {
60: if (test) {
61: throw new IllegalArgumentException("Assert.isFalse failed");
62: }
63: }
64:
65: public static void isNotNull(final Object test) {
66: if (test == null) {
67: throw new IllegalArgumentException(
68: "Assert.isNotNull failed");
69: }
70: }
71:
72: public static void isNull(final Object test) {
73: if (test != null) {
74: throw new IllegalArgumentException("Assert.isNull failed");
75: }
76: }
77: }
|