Module lettuce.core

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 Details

    • notEmpty

      public static void notEmpty​(CharSequence string, String message)
      Assert that a string is not empty, it must not be null and it must not be empty.
      Parameters:
      string - the object to check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object is null 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 be null and it must not be empty.
      Parameters:
      string - the object to check
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object is null or the underlying string is empty
      Since:
      5.2.0
    • notNull

      public static void notNull​(Object object, String message)
      Assert that an object is not null .
      Parameters:
      object - the object to check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object is null
    • notNull

      public static void notNull​(Object object, Supplier<String> messageSupplier)
      Assert that an object is not null .
      Parameters:
      object - the object to check
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object is null
      Since:
      5.2.0
    • notEmpty

      public static void notEmpty​(Object[] array, String message)
      Assert that an array has elements; that is, it must not be null and must have at least one element.
      Parameters:
      array - the array to check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array is null 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 be null and must have at least one element.
      Parameters:
      array - the array to check
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array is null 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 be null and must have at least one element.
      Parameters:
      array - the array to check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array is null 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 check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array contains a null element
    • noNullElements

      public static void noNullElements​(Object[] array, Supplier<String> messageSupplier)
      Assert that an array has no null elements.
      Parameters:
      array - the array to check
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array contains a null element
      Since:
      5.2.0
    • noNullElements

      public static void noNullElements​(Collection<?> c, String message)
      Assert that a Collection has no null elements.
      Parameters:
      c - the collection to check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the Collection contains a null element
    • noNullElements

      public static void noNullElements​(Collection<?> c, Supplier<String> messageSupplier)
      Assert that a Collection has no null elements.
      Parameters:
      c - the collection to check
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalArgumentException - if the Collection contains a null element
      Since:
      5.2.0
    • isTrue

      public static void isTrue​(boolean value, String message)
      Assert that value is true.
      Parameters:
      value - the value to check
      message - the exception message to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array contains a null element
    • isTrue

      public static void isTrue​(boolean value, Supplier<String> messageSupplier)
      Assert that value is true.
      Parameters:
      value - the value to check
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalArgumentException - if the object array contains a null 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 expression
      message - the exception message to use if the assertion fails
      Throws:
      IllegalStateException - if expression 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 expression
      messageSupplier - the exception message supplier to use if the assertion fails
      Throws:
      IllegalStateException - if expression is false
      Since:
      5.2.0