Class Assert


  • public final class Assert
    extends java.lang.Object
    General assertion utilities
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String HAS_NO_TEXT  
      private static java.lang.String IS_EMPTY  
      private static java.lang.String IS_FALSE  
      private static java.lang.String IS_NULL  
      private static java.lang.String IS_TRUE  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Assert()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T assertThat​(boolean condition, java.lang.String propOrMsg, java.lang.String msgSuffix, T rv)
      General assertion mwthos
      static java.lang.String hasLength​(java.lang.String str, java.lang.String propOrMsg)
      Assert that the given String is not empty
      static java.lang.String hasText​(java.lang.String str, java.lang.String propOrMsg)
      Assert that the given String has actual non-whitepsace text.
      static boolean isFalse​(boolean condition, java.lang.String propOrMsg)
      Assert that the given condition is true
      static boolean isTrue​(boolean condition, java.lang.String propOrMsg)
      Assert that the given condition is true
      static <C extends java.util.Collection<?>>
      C
      notEmpty​(C col, java.lang.String propOrMsg)
      Assert that the given Collection is not empty
      static <M extends java.util.Map<?,​?>>
      M
      notEmpty​(M map, java.lang.String propOrMsg)
      Assert that the given Map is not empty
      static <T> T[] notEmpty​(T[] objects, java.lang.String propOrMsg)
      Assert that the given array is not empty
      static <T> T notNull​(T object, java.lang.String propOrMsg)
      Assert that the given object is not null
      • 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

      • hasText

        public static java.lang.String hasText​(java.lang.String str,
                                               java.lang.String propOrMsg)
        Assert that the given String has actual non-whitepsace text.
        Parameters:
        str -
        propOrMsg -
        Returns:
      • notNull

        public static <T> T notNull​(T object,
                                    java.lang.String propOrMsg)
        Assert that the given object is not null
        Type Parameters:
        T -
        Parameters:
        object -
        propOrMsg -
        Returns:
      • hasLength

        public static java.lang.String hasLength​(java.lang.String str,
                                                 java.lang.String propOrMsg)
        Assert that the given String is not empty
        Parameters:
        str -
        propOrMsg -
        Returns:
      • notEmpty

        public static <T> T[] notEmpty​(T[] objects,
                                       java.lang.String propOrMsg)
        Assert that the given array is not empty
        Type Parameters:
        T -
        Parameters:
        objects -
        propOrMsg -
        Returns:
      • notEmpty

        public static <M extends java.util.Map<?,​?>> M notEmpty​(M map,
                                                                      java.lang.String propOrMsg)
        Assert that the given Map is not empty
        Type Parameters:
        M -
        Parameters:
        map -
        propOrMsg -
        Returns:
      • notEmpty

        public static <C extends java.util.Collection<?>> C notEmpty​(C col,
                                                                     java.lang.String propOrMsg)
        Assert that the given Collection is not empty
        Type Parameters:
        C -
        Parameters:
        col -
        propOrMsg -
        Returns:
      • isTrue

        public static boolean isTrue​(boolean condition,
                                     java.lang.String propOrMsg)
        Assert that the given condition is true
        Parameters:
        condition -
        propOrMsg -
        Returns:
      • isFalse

        public static boolean isFalse​(boolean condition,
                                      java.lang.String propOrMsg)
        Assert that the given condition is true
        Parameters:
        condition -
        propOrMsg -
        Returns:
      • assertThat

        public static <T> T assertThat​(boolean condition,
                                       java.lang.String propOrMsg,
                                       java.lang.String msgSuffix,
                                       T rv)
        General assertion mwthos
        Type Parameters:
        T -
        Parameters:
        condition -
        propOrMsg -
        msgSuffix -
        rv -
        Returns: