1 11 package org.eclipse.team.internal.core; 12 13 import org.eclipse.osgi.util.NLS; 14 15 16 17 public final class Assert { 18 public static class AssertionFailedException extends RuntimeException { 19 private static final long serialVersionUID = -3361573629971779153L; 21 public AssertionFailedException() { 22 } 23 public AssertionFailedException(String detail) { 24 super(NLS.bind(Messages.Assert_assertionFailed, new String [] { detail })); } 26 } 27 28 private Assert() { 29 } 30 39 public static boolean isLegal(boolean expression) { 40 return isLegal(expression, ""); } 42 53 public static boolean isLegal(boolean expression, String message) { 54 if (!expression) 55 throw new IllegalArgumentException (message); 56 return expression; 57 } 58 64 public static void isNotNull(Object object) { 65 if (object == null) 66 throw new AssertionFailedException("null argument"); } 68 76 public static void isNotNull(Object object, String message) { 77 if (object == null) 78 throw new AssertionFailedException("null argument:" + message); } 80 87 public static boolean isTrue(boolean expression) { 88 return isTrue(expression, ""); } 90 99 public static boolean isTrue(boolean expression, String message) { 100 if (!expression) 101 throw new AssertionFailedException("assert failed:" + message); return expression; 103 } 104 108 public static void notYetImplemented() { 109 } 110 } 111 | Popular Tags |