public final class Assertion extends Object
This class contains a set of static utility methods for assertion checking. Assertions are used to document the assumptions a programmer is making about the code they are writing. Assertions should not be used in cases where the user of a class can affect whether the assertion is true or false, such as argument checking. Rather, assertions should be considered a much stronger statement by the programmer that such a condition is NEVER true. In fact, this statement is so strong that assertions should be considered optional as they should never occur. However, these assertions may be violated during development and that is primarily where these assertions are useful.
In JDK 1.4, Sun introduces the "assert" keyword and builds assertion support directly into the language. When MetaMatrix begins using JDK 1.4 across the board, this class should no longer be needed and all usage of assertions should be replaced with use of the built-in JDK assertion facility.
Modifier and Type | Method and Description |
---|---|
static void |
assertTrue(boolean condition) |
static void |
assertTrue(boolean condition,
String msgKey) |
static void |
failed(String msg) |
static <T> T |
isInstanceOf(Object object,
Class<T> expectedClass,
String name)
Verifies that the specified value is an instance of the specified class.
|
static void |
isNotNull(Object value) |
static void |
isNotNull(Object value,
String message) |
static void |
isNull(Object value) |
static void |
isNull(Object value,
String message) |
public static final void assertTrue(boolean condition)
public static final void assertTrue(boolean condition, String msgKey)
public static final void failed(String msg)
public static final void isNull(Object value)
public static final void isNotNull(Object value)
public static final <T> T isInstanceOf(Object object, Class<T> expectedClass, String name)
object
- The value to verifyexpectedClass
- The class of which the value must be an instancename
- The text identifying the name or type of valueClassCastException
- If the value is not an instance of the specified class.Copyright © 2019. All rights reserved.