1 11 package org.eclipse.jdt.internal.corext; 12 13 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages; 14 15 33 public final class Assert { 34 35 44 private static class AssertionFailedException extends RuntimeException { 45 46 private static final long serialVersionUID= 1L; 47 48 51 public AssertionFailedException() { 52 } 53 54 58 public AssertionFailedException(String detail) { 59 super(detail); 60 } 61 } 62 63 64 private Assert() { 65 } 66 67 82 public static void isNotNull(Object object) { 83 if (object != null) { 85 return; 86 } 87 isNotNull(object, ""); } 89 90 107 public static void isNotNull(Object object, String message) { 108 if (object == null) 109 throw new AssertionFailedException(RefactoringCoreMessages.Assert_null_argument + message); 110 } 111 112 120 public static boolean isTrue(boolean expression) { 121 if (expression) { 123 return true; 124 } 125 return isTrue(expression, ""); } 127 128 138 public static boolean isTrue(boolean expression, String message) { 139 if (!expression) 140 throw new AssertionFailedException(RefactoringCoreMessages.Assert_assertion_failed + message); 141 return expression; 142 } 143 144 } 145 | Popular Tags |