Package org.eclipse.core.runtime
Class Assert
java.lang.Object
org.eclipse.core.runtime.Assert
Assert
is useful for for embedding runtime sanity checks in
code. The 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 (and certainly should not be catching them specifically).
This class can be used without OSGi running.
This class is not intended to be instantiated or sub-classed by clients.
- Since:
- org.eclipse.equinox.common 3.2
- Restriction:
- This class is not intended to be instantiated by clients.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
isLegal
(boolean expression) Asserts that an argument is legal.static boolean
Asserts that an argument is legal.static void
Asserts that the given object is notnull
.static void
Asserts that the given object is notnull
.static boolean
isTrue
(boolean expression) Asserts that the given boolean istrue
.static boolean
Asserts that the given boolean istrue
.
-
Method Details
-
isLegal
public static boolean isLegal(boolean expression) Asserts that an argument is legal. If the given boolean is nottrue
, anIllegalArgumentException
is thrown.- Parameters:
expression
- the outcome of the check- Returns:
true
if the check passes (does not return if the check fails)- Throws:
IllegalArgumentException
- if the legality test failed
-
isLegal
Asserts that an argument is legal. If the given boolean is nottrue
, anIllegalArgumentException
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:
true
if the check passes (does not return if the check fails)- Throws:
IllegalArgumentException
- if the legality test failed
-
isNotNull
Asserts that the given object is notnull
. If this is not the case, some kind of unchecked exception is thrown.- Parameters:
object
- the value to test
-
isNotNull
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.- Parameters:
object
- the value to testmessage
- the message to include in the exception
-
isTrue
public static boolean isTrue(boolean expression) 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:
true
if the check passes (does not return if the check fails)
-
isTrue
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:
true
if the check passes (does not return if the check fails)
-