@ThreadSafe public final class Assertions extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
assertInRangeInclusive(double actual,
double minInclusive,
double maxInclusive,
String name) |
static void |
assertInRangeInclusive(float actual,
float minInclusive,
float maxInclusive,
String name) |
static void |
assertInRangeInclusive(int actual,
int minInclusive,
int maxInclusive,
String name) |
static void |
assertInRangeInclusive(long actual,
long minInclusive,
long maxInclusive,
String name) |
static void |
assertInSet(Object obj,
Object... set) |
static void |
assertIsMainThread() |
static void |
assertIsNotMainThread() |
static void |
assertNoNullElements(Collection<?> collection,
String name) |
static void |
assertNoNullElements(Map<?,?> map,
String name) |
static void |
assertNoNullElements(Object[] array,
String name) |
static void |
assertNotEmpty(Collection<?> collection,
String name) |
static void |
assertNotEmpty(Map<?,?> map,
String name) |
static void |
assertNotEmpty(String string,
String name) |
static <T> T |
assertNotNull(T object,
String name) |
public static void assertInRangeInclusive(int actual,
int minInclusive,
int maxInclusive,
@NonNull
String name)
actual - Value to check whether it is in the range [ minInclusive,
maxInclusive].minInclusive - Minimum value for actual.maxInclusive - Maximum value for actual.name - Name of the value for human-readable exceptions.AssertionError - If actual is outside the range [ minInclusive,
maxInclusive].public static void assertInRangeInclusive(long actual,
long minInclusive,
long maxInclusive,
@NonNull
String name)
actual - Value to check whether it is in the range [ minInclusive,
maxInclusive].minInclusive - Minimum value for actual.maxInclusive - Maximum value for actual.name - Name of the value for human-readable exceptions.AssertionError - If actual is outside the range [ minInclusive,
maxInclusive].public static void assertInRangeInclusive(float actual,
float minInclusive,
float maxInclusive,
@NonNull
String name)
actual - Value to check whether it is in the range [ minInclusive,
maxInclusive].minInclusive - Minimum value for actual.maxInclusive - Maximum value for actual.name - Name of the value for human-readable exceptions.AssertionError - If actual is outside the range [ minInclusive,
maxInclusive].public static void assertInRangeInclusive(double actual,
double minInclusive,
double maxInclusive,
@NonNull
String name)
actual - Value to check whether it is in the range [ minInclusive,
maxInclusive].minInclusive - Minimum value for actual.maxInclusive - Maximum value for actual.name - Name of the value for human-readable exceptions.AssertionError - If actual is outside the range [ minInclusive,
maxInclusive].public static void assertNoNullElements(@Nullable Object[] array, @Nullable String name)
array - Array to check for being null or containing null elements.name - Name of the array for human-readable exceptions.AssertionError - If array is null or empty.public static void assertNoNullElements(@Nullable Collection<?> collection, @Nullable String name)
collection - Collection to check for being null or containing null elements.name - Name of the Collection for human-readable exceptions.AssertionError - If collection is null or empty.public static void assertNoNullElements(@Nullable Map<?,?> map, @Nullable String name)
map - Map to check for being null or containing null keys or null values.name - Name of the Map for human-readable exceptions.AssertionError - If map is null or empty.public static void assertInSet(@Nullable Object obj, @NonNull Object... set)
obj - Object to check if it is within set.set - Allowed elements for obj. set must not be null, but may
contain null elements.@NonNull public static <T> T assertNotNull(@Nullable T object, @NonNull String name)
object - Object to check for being null.name - Name of the object for human-readable exceptions.object sanitized as being non-null.AssertionError - If object is null.public static void assertNotEmpty(@Nullable String string, @NonNull String name)
string - String to check for being null or empty.name - Name of the String for human-readable exceptions.AssertionError - If string is null or empty.public static void assertNotEmpty(@Nullable Collection<?> collection, @NonNull String name)
collection - Collection to check for being null or empty.name - Name of the Collection for human-readable exceptions.AssertionError - If collection is null or empty.public static void assertNotEmpty(@Nullable Map<?,?> map, @NonNull String name)
map - Map to check for being null or empty.name - Name of the Map for human-readable exceptions.AssertionError - If map is null or empty.public static void assertIsMainThread()
AssertionError - If the current thread is not the main application thread.public static void assertIsNotMainThread()
AssertionError - If the current thread is not the main application thread.