1 11 package org.eclipse.update.internal.core; 12 13 26 public final class Assert { 27 28 37 private static class AssertionFailedException extends RuntimeException { 38 39 private static final long serialVersionUID = 1L; 40 41 44 public AssertionFailedException() { 45 } 46 47 50 public AssertionFailedException(String detail) { 51 super(detail); 52 } 53 } 54 55 private Assert() { 56 } 57 67 public static boolean isLegal(boolean expression) { 68 if (expression) { 70 return true; 71 } 72 return isLegal(expression, "");} 74 86 public static boolean isLegal(boolean expression, String message) { 87 if (!expression) 88 throw new IllegalArgumentException (message); 89 return expression; 90 } 91 107 public static void isNotNull(Object object) { 108 if (object != null) { 110 return; 111 } 112 isNotNull(object, "");} 114 132 public static void isNotNull(Object object, String message) { 133 if (object == null) 134 throw new AssertionFailedException("null argument;" + message);} 136 144 public static boolean isTrue(boolean expression) { 145 if (expression) { 147 return true; 148 } 149 return isTrue(expression, "");} 151 161 public static boolean isTrue(boolean expression, String message) { 162 if (!expression) 163 throw new AssertionFailedException("assertion failed; "+message); return expression; 165 } 166 } 167 168 169 | Popular Tags |