1 11 package org.eclipse.test.internal.performance.data; 12 13 14 31 public final class Assert { 32 33 42 private static class AssertionFailedException extends RuntimeException { 43 44 private static final long serialVersionUID = 1L; 45 46 49 public AssertionFailedException() { 50 } 52 53 58 public AssertionFailedException(String detail) { 59 super(detail); 60 } 61 } 62 63 64 private Assert() { 65 } 67 68 78 public static boolean isLegal(boolean expression) { 79 if (expression) { 81 return true; 82 } 83 return isLegal(expression, ""); } 85 86 98 public static boolean isLegal(boolean expression, String message) { 99 if (!expression) 100 throw new IllegalArgumentException ("assertion failed; " + message); return expression; 102 } 103 104 119 public static void isNotNull(Object object) { 120 if (object != null) { 122 return; 123 } 124 isNotNull(object, ""); } 126 127 144 public static void isNotNull(Object object, String message) { 145 if (object == null) 146 throw new AssertionFailedException("null argument;" + message); } 148 149 157 public static boolean isTrue(boolean expression) { 158 if (expression) { 160 return true; 161 } 162 return isTrue(expression, ""); } 164 165 175 public static boolean isTrue(boolean expression, String message) { 176 if (!expression) 177 throw new AssertionFailedException("Assertion failed: "+message); return expression; 179 } 180 } 181 | Popular Tags |