
public final class Assert extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
assertHoldsLock(T monitor)
Assert that the given monitor is held by the current thread.
|
static <T> T |
assertNotHoldsLock(T monitor)
Assert that the given monitor is not held by the current thread.
|
static <T> T |
assertNotNull(T value)
Assert that the value is not
null. |
static <T> T |
checkNotNullParam(String name,
T value)
Check that the named parameter is not
null. |
static IllegalStateException |
impossibleSwitchCase(int val)
Return an exception indicating that the current switch case was intended to be unreachable.
|
static IllegalStateException |
impossibleSwitchCase(long val)
Return an exception indicating that the current switch case was intended to be unreachable.
|
static IllegalStateException |
impossibleSwitchCase(Object obj)
Return an exception indicating that the current switch case was intended to be unreachable.
|
static IllegalStateException |
unreachableCode()
Return an exception indicating that the current code was intended to be unreachable.
|
@NotNull public static <T> T checkNotNullParam(String name, T value) throws IllegalArgumentException
null. Use a standard exception message if it is.T - the value typename - the parameter namevalue - the parameter valueIllegalArgumentException - if the value is null@NotNull public static <T> T assertNotNull(T value)
null. Use a standard assertion failure message if it is. Only
runs if assert is enabled.T - the value typevalue - the not-null value@NotNull
public static <T> T assertHoldsLock(@NotNull
T monitor)
assert is enabled.T - the monitor's typemonitor - the monitor objectIllegalArgumentException - if the monitor is null@NotNull
public static <T> T assertNotHoldsLock(@NotNull
T monitor)
assert is enabled.T - the monitor's typemonitor - the monitor objectIllegalArgumentException - if the monitor is nullpublic static IllegalStateException unreachableCode()
@NotNull public static IllegalStateException impossibleSwitchCase(@NotNull Object obj)
obj - the switch case value@NotNull public static IllegalStateException impossibleSwitchCase(int val)
val - the switch case value@NotNull public static IllegalStateException impossibleSwitchCase(long val)
val - the switch case valueCopyright © 2015 JBoss, a division of Red Hat, Inc.