Package io.lettuce.core.internal
Class LettuceAssert
- java.lang.Object
-
- io.lettuce.core.internal.LettuceAssert
-
public class LettuceAssert extends Object
Assertion utility class that assists in validating arguments. This class is part of the internal API and may change without further notice.- Author:
- Mark Paluch
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertState(boolean condition, String message)
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static void
assertState(boolean condition, Supplier<String> messageSupplier)
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.static void
isTrue(boolean value, String message)
Assert thatvalue
istrue
.static void
isTrue(boolean value, Supplier<String> messageSupplier)
Assert thatvalue
istrue
.static void
noNullElements(Object[] array, String message)
Assert that an array has no null elements.static void
noNullElements(Object[] array, Supplier<String> messageSupplier)
Assert that an array has no null elements.static void
noNullElements(Collection<?> c, String message)
Assert that aCollection
has no null elements.static void
noNullElements(Collection<?> c, Supplier<String> messageSupplier)
Assert that aCollection
has no null elements.static void
notEmpty(int[] array, String message)
Assert that an array has elements; that is, it must not benull
and must have at least one element.static void
notEmpty(CharSequence string, String message)
Assert that a string is not empty, it must not benull
and it must not be empty.static void
notEmpty(CharSequence string, Supplier<String> messageSupplier)
Assert that a string is not empty, it must not benull
and it must not be empty.static void
notEmpty(Object[] array, String message)
Assert that an array has elements; that is, it must not benull
and must have at least one element.static void
notEmpty(Object[] array, Supplier<String> messageSupplier)
Assert that an array has elements; that is, it must not benull
and must have at least one element.static void
notNull(Object object, String message)
Assert that an object is notnull
.static void
notNull(Object object, Supplier<String> messageSupplier)
Assert that an object is notnull
.
-
-
-
Method Detail
-
notEmpty
public static void notEmpty(CharSequence string, String message)
Assert that a string is not empty, it must not benull
and it must not be empty.- Parameters:
string
- the object to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if the object isnull
or the underlying string is empty
-
notEmpty
public static void notEmpty(CharSequence string, Supplier<String> messageSupplier)
Assert that a string is not empty, it must not benull
and it must not be empty.- Parameters:
string
- the object to checkmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalArgumentException
- if the object isnull
or the underlying string is empty- Since:
- 5.2.0
-
notNull
public static void notNull(Object object, String message)
Assert that an object is notnull
.- Parameters:
object
- the object to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if the object isnull
-
notNull
public static void notNull(Object object, Supplier<String> messageSupplier)
Assert that an object is notnull
.- Parameters:
object
- the object to checkmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalArgumentException
- if the object isnull
- Since:
- 5.2.0
-
notEmpty
public static void notEmpty(Object[] array, String message)
Assert that an array has elements; that is, it must not benull
and must have at least one element.- Parameters:
array
- the array to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array isnull
or has no elements
-
notEmpty
public static void notEmpty(Object[] array, Supplier<String> messageSupplier)
Assert that an array has elements; that is, it must not benull
and must have at least one element.- Parameters:
array
- the array to checkmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array isnull
or has no elements- Since:
- 5.2.0
-
notEmpty
public static void notEmpty(int[] array, String message)
Assert that an array has elements; that is, it must not benull
and must have at least one element.- Parameters:
array
- the array to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array isnull
or has no elements
-
noNullElements
public static void noNullElements(Object[] array, String message)
Assert that an array has no null elements.- Parameters:
array
- the array to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array contains anull
element
-
noNullElements
public static void noNullElements(Object[] array, Supplier<String> messageSupplier)
Assert that an array has no null elements.- Parameters:
array
- the array to checkmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array contains anull
element- Since:
- 5.2.0
-
noNullElements
public static void noNullElements(Collection<?> c, String message)
Assert that aCollection
has no null elements.- Parameters:
c
- the collection to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if theCollection
contains anull
element
-
noNullElements
public static void noNullElements(Collection<?> c, Supplier<String> messageSupplier)
Assert that aCollection
has no null elements.- Parameters:
c
- the collection to checkmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalArgumentException
- if theCollection
contains anull
element- Since:
- 5.2.0
-
isTrue
public static void isTrue(boolean value, String message)
Assert thatvalue
istrue
.- Parameters:
value
- the value to checkmessage
- the exception message to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array contains anull
element
-
isTrue
public static void isTrue(boolean value, Supplier<String> messageSupplier)
Assert thatvalue
istrue
.- Parameters:
value
- the value to checkmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalArgumentException
- if the object array contains anull
element- Since:
- 5.2.0
-
assertState
public static void assertState(boolean condition, String message)
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
condition
- a boolean expressionmessage
- the exception message to use if the assertion fails- Throws:
IllegalStateException
- ifexpression
is false
-
assertState
public static void assertState(boolean condition, Supplier<String> messageSupplier)
Ensures the truth of an expression involving the state of the calling instance, but not involving any parameters to the calling method.- Parameters:
condition
- a boolean expressionmessageSupplier
- the exception message supplier to use if the assertion fails- Throws:
IllegalStateException
- ifexpression
is false- Since:
- 5.2.0
-
-