|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unkrig.commons.lang.AssertionUtil
public final class AssertionUtil
Various assertion-related utility methods.
| Method Summary | ||
|---|---|---|
static void |
enableAssertionsFor(java.lang.Class<?> clasS)
Enables assertions for the given clasS, regardless of the "enable assertions" command line options that
the JVM was start with. |
|
static void |
enableAssertionsForThisClass()
Enables assertions for the class that invokes this method, regardless of the "enable assertions" command line options that the JVM was start with. |
|
static java.lang.Object |
fail()
Identical with ' throw new AssertionError()', but returns an Object so it can be used in an
expression. |
|
static
|
fail(java.lang.String message)
Identical with ' throw new AssertionError(message)', but returns an Object so it can be used in
an expression. |
|
static java.lang.Object |
fail(java.lang.String message,
java.lang.Throwable cause)
Identical with ' throw new AssertionError(message, cause)', but returns an Object so it can be
used in an expression. |
|
static java.lang.Object |
fail(java.lang.Throwable cause)
Identical with ' throw new AssertionError(cause)', but returns an Object so it can be used in
an expression. |
|
static
|
notNull(T subject)
Verifies that the subject is not null. |
|
static
|
notNull(T subject,
java.lang.String message)
Verifies that the subject is not null. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void enableAssertionsFor(java.lang.Class<?> clasS)
clasS, regardless of the "enable assertions" command line options that
the JVM was start with.
Enabling assertions programmatically makes them much more helpful, because unfortunately assertions are disabled
by default and hardly any runtime environment provides a simple way to enable them.
enableAssertionsForThisClass() is an even more elegant way to enable assertions for classes as they
are loaded and initialized.
public static void enableAssertionsForThisClass()
public class MyClass {
static { AssertionUtil.enableAssertionsForThisClass(); }
// ...
}
Adding such static initializers to all classes makes assertions much more helpful, because unfortunately
assertions are disabled by default and hardly any runtime environment provides a simple way to enable them.
Must only be called from the static initializer of a class.
public static <T> T notNull(@Nullable
T subject)
subject is not null.
subject
java.lang.NullPointerException
public static <T> T notNull(@Nullable
T subject,
java.lang.String message)
subject is not null.
subject
java.lang.NullPointerException - with the given message iff the subject is nullpublic static java.lang.Object fail()
throw new AssertionError()', but returns an Object so it can be used in an
expression.
public static <T> T fail(java.lang.String message)
throw new AssertionError(message)', but returns an Object so it can be used in
an expression.
public static java.lang.Object fail(java.lang.Throwable cause)
throw new AssertionError(cause)', but returns an Object so it can be used in
an expression.
public static java.lang.Object fail(java.lang.String message,
java.lang.Throwable cause)
throw new AssertionError(message, cause)', but returns an Object so it can be
used in an expression.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||