public final class Assertions extends Object
Modifier and Type | Method | Description |
---|---|---|
static <T> T |
cast(String name,
Object value) |
Cast an object to T.
|
static void |
isTrue(String name,
boolean condition) |
Throw IllegalStateException if the condition is false.
|
static <T> T |
notNull(String name,
T value) |
Throw IllegalArgumentException if the value is null.
|
public static <T> T notNull(String name, T value)
T
- the value typename
- the parameter namevalue
- the value that should not be nullIllegalArgumentException
- if value is nullpublic static void isTrue(String name, boolean condition)
name
- the name of the state that is being checkedcondition
- the condition about the parameter to checkIllegalStateException
- if the condition is falsepublic static <T> T cast(String name, Object value)
T
- the type to cast toname
- the parameter namevalue
- the value to cast fromIllegalArgumentException
- if the value is not