1 11 package org.eclipse.jdt.internal.core; 12 13 14 public final class Assert { 15 16 private Assert() { 17 } 19 28 public static boolean isLegal(boolean expression) { 29 return isLegal(expression, ""); } 31 42 public static boolean isLegal(boolean expression, String message) { 43 if (!expression) 44 throw new IllegalArgumentException (message); 45 return expression; 46 } 47 53 public static void isNotNull(Object object) { 54 isNotNull(object, ""); } 56 64 public static void isNotNull(Object object, String message) { 65 if (object == null) 66 throw new AssertionFailedException("null argument; " + message); } 68 75 public static boolean isTrue(boolean expression) { 76 return isTrue(expression, ""); } 78 87 public static boolean isTrue(boolean expression, String message) { 88 if (!expression) 89 throw new AssertionFailedException("Assertion failed; " + message); return expression; 91 } 92 93 public static class AssertionFailedException extends RuntimeException { 94 private static final long serialVersionUID = -3179320974982211564L; public AssertionFailedException(String detail) { 96 super(detail); 97 } 98 } 99 } 100 | Popular Tags |