Class Assert


  • public final class Assert
    extends java.lang.Object
    Utility class providing common validation logic.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Assert()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isEmpty​(java.lang.Object o)
      Checks if an object has empty semantics.
      static boolean isNonEmpty​(java.lang.Object o)
      Opposite of isEmpty(Object).
      static <T> T requireNonEmpty​(T value)
      Checks a value for emptiness and throws an IllegalArgumentException if it's empty.
      static <T> T requireNonEmpty​(T value, java.lang.String message)
      Checks a value for emptiness and throws an IllegalArgumentException if it's empty.
      static int valueIsAtLeast​(int value, int minValue)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Assert

        private Assert()
    • Method Detail

      • isEmpty

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

        public static boolean isNonEmpty​(java.lang.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,
                                            java.lang.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)