Class Assert

java.lang.Object
org.apache.logging.log4j.core.util.Assert

public final class Assert extends Object
Utility class providing common validation logic.
  • Method Details

    • isEmpty

      public static boolean isEmpty(Object o)
      Checks if an object has empty semantics. The following scenarios are considered empty:
      Parameters:
      o - value to check for emptiness
      Returns:
      true if the value is empty, false otherwise
      Since:
      2.8
    • isNonEmpty

      public static boolean isNonEmpty(Object o)
      Opposite of isEmpty(Object).
      Parameters:
      o - value to check for non-emptiness
      Returns:
      true if the value is non-empty, false otherwise
      Since:
      2.8
    • requireNonEmpty

      public static <T> T requireNonEmpty(T value)
      Checks a value for emptiness and throws an IllegalArgumentException if it's empty.
      Type Parameters:
      T - type of value
      Parameters:
      value - value to check for emptiness
      Returns:
      the provided value if non-empty
      Since:
      2.8
    • requireNonEmpty

      public static <T> T requireNonEmpty(T value, String message)
      Checks a value for emptiness and throws an IllegalArgumentException if it's empty.
      Type Parameters:
      T - type of value
      Parameters:
      value - value to check for emptiness
      message - message to provide in exception
      Returns:
      the provided value if non-empty
      Since:
      2.8
    • valueIsAtLeast

      public static int valueIsAtLeast(int value, int minValue)