Class Assert
- java.lang.Object
-
- org.eclipse.jface.text.Assert
-
@Deprecated public final class Assert extends Object
Deprecated.As of 3.3, replaced byAssertAssertis useful for for embedding runtime sanity checks in code. The static predicate methods all test a condition and throw some type of unchecked exception if the condition does not hold.Assertion failure exceptions, like most runtime exceptions, are thrown when something is misbehaving. Assertion failures are invariably unspecified behavior; consequently, clients should never rely on these being thrown (or not thrown). If you find yourself in the position where you need to catch an assertion failure, you have most certainly written your program incorrectly.
Note that an
assertstatement is slated to be added to the Java language in JDK 1.4, rending this class obsolete.- Restriction:
- This class is planned to be deleted, see Bug 528191
- Restriction:
- This class is not intended to be instantiated by clients.
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static booleanisLegal(boolean expression)Deprecated.Asserts that an argument is legal.static booleanisLegal(boolean expression, String message)Deprecated.Asserts that an argument is legal.static voidisNotNull(Object object)Deprecated.Asserts that the given object is notnull.static voidisNotNull(Object object, String message)Deprecated.Asserts that the given object is notnull.static booleanisTrue(boolean expression)Deprecated.Asserts that the given boolean istrue.static booleanisTrue(boolean expression, String message)Deprecated.Asserts that the given boolean istrue.
-
-
-
Method Detail
-
isLegal
public static boolean isLegal(boolean expression)
Deprecated.Asserts that an argument is legal. If the given boolean is nottrue, anIllegalArgumentExceptionis thrown.- Parameters:
expression- the outcome of the check- Returns:
trueif the check passes (does not return if the check fails)- Throws:
IllegalArgumentException- if the legality test failed
-
isLegal
public static boolean isLegal(boolean expression, String message)Deprecated.Asserts that an argument is legal. If the given boolean is nottrue, anIllegalArgumentExceptionis thrown. The given message is included in that exception, to aid debugging.- Parameters:
expression- the outcome of the checkmessage- the message to include in the exception- Returns:
trueif the check passes (does not return if the check fails)- Throws:
IllegalArgumentException- if the legality test failed
-
isNotNull
public static void isNotNull(Object object)
Deprecated.Asserts that the given object is notnull. If this is not the case, some kind of unchecked exception is thrown.As a general rule, parameters passed to API methods must not be
nullunless explicitly allowed in the method's specification. Similarly, results returned from API methods are nevernullunless explicitly allowed in the method's specification. Implementations are encouraged to make regular use ofAssert.isNotNullto ensure thatnullparameters are detected as early as possible.- Parameters:
object- the value to test- Throws:
RuntimeException- an unspecified unchecked exception if the object isnull
-
isNotNull
public static void isNotNull(Object object, String message)
Deprecated.Asserts that the given object is notnull. If this is not the case, some kind of unchecked exception is thrown. The given message is included in that exception, to aid debugging.As a general rule, parameters passed to API methods must not be
nullunless explicitly allowed in the method's specification. Similarly, results returned from API methods are nevernullunless explicitly allowed in the method's specification. Implementations are encouraged to make regular use ofAssert.isNotNullto ensure thatnullparameters are detected as early as possible.- Parameters:
object- the value to testmessage- the message to include in the exception- Throws:
RuntimeException- an unspecified unchecked exception if the object isnull
-
isTrue
public static boolean isTrue(boolean expression)
Deprecated.Asserts that the given boolean istrue. If this is not the case, some kind of unchecked exception is thrown.- Parameters:
expression- the outcome of the check- Returns:
trueif the check passes (does not return if the check fails)
-
isTrue
public static boolean isTrue(boolean expression, String message)Deprecated.Asserts that the given boolean istrue. If this is not the case, some kind of unchecked exception is thrown. The given message is included in that exception, to aid debugging.- Parameters:
expression- the outcome of the checkmessage- the message to include in the exception- Returns:
trueif the check passes (does not return if the check fails)
-
-