Class Assert


  • public class Assert
    extends Object
    基本断言类,抛出断言异常信息
    Author:
    liuzh
    • Constructor Detail

      • Assert

        public Assert()
    • Method Detail

      • isTrue

        public static void isTrue​(boolean expression,
                                  String message)
        断言是否为真
        Parameters:
        expression - 布尔值
        message - 异常消息
      • isTrue

        public static void isTrue​(boolean expression,
                                  Code code)
        断言是否为真
        Parameters:
        expression - 布尔值
        code - 错误码
      • isFalse

        public static void isFalse​(boolean expression,
                                   String message)
        断言是否为假
        Parameters:
        expression - 布尔值
        message - 异常消息
      • isFalse

        public static void isFalse​(boolean expression,
                                   Code code)
        断言是否为假
        Parameters:
        expression - 布尔值
        code - 错误码
      • isNull

        public static void isNull​(Object object,
                                  String message)
        断言对象是否为null
        Parameters:
        object - 被检查的对象
        message - 异常消息
      • isNull

        public static void isNull​(Object object,
                                  Code code)
        断言对象是否为null
        Parameters:
        object - 被检查的对象
        code - 错误码
      • notNull

        public static void notNull​(Object object,
                                   String message)
        断言对象是否不为null
        Parameters:
        object - 被检查的对象
        message - 异常消息
      • notNull

        public static void notNull​(Object object,
                                   Code code)
        断言对象是否补为null
        Parameters:
        object - 被检查的对象
        code - 错误码
      • isEmpty

        public static <T extends CharSequence> void isEmpty​(T text,
                                                            String message)
        检查给定字符串是否为空
        Parameters:
        text - 字符串类型
        message - 异常消息
      • isEmpty

        public static <T extends CharSequence> void isEmpty​(T text,
                                                            Code code)
        检查给定字符串是否为空
        Parameters:
        text - 字符串类型
        code - 错误码
      • notEmpty

        public static <T extends CharSequence> void notEmpty​(T text,
                                                             String message)
        检查给定字符串是否为空
        Parameters:
        text - 字符串类型
        message - 异常消息
      • notEmpty

        public static <T extends CharSequence> void notEmpty​(T text,
                                                             Code code)
        检查给定字符串是否为空
        Parameters:
        text - 字符串类型
        code - 错误码
      • isBlank

        public static <T extends CharSequence> void isBlank​(T text,
                                                            String message)
        检查给定字符串是否为空白(null、空串或只包含空白符)
        Parameters:
        text - 字符串类型
        message - 异常消息
      • isBlank

        public static <T extends CharSequence> void isBlank​(T text,
                                                            Code code)
        检查给定字符串是否为空白(null、空串或只包含空白符)
        Parameters:
        text - 字符串类型
        code - 错误码
      • notBlank

        public static <T extends CharSequence> void notBlank​(T text,
                                                             String message)
        检查给定字符串是否为空白(null、空串或只包含空白符)
        Parameters:
        text - 字符串类型
        message - 异常消息
      • notBlank

        public static <T extends CharSequence> void notBlank​(T text,
                                                             Code code)
        检查给定字符串是否为空白(null、空串或只包含空白符)
        Parameters:
        text - 字符串类型
        code - 错误码
      • isEmpty

        public static <T> void isEmpty​(T[] array,
                                       String message)
        检查给定数组是否为空
        Parameters:
        array - 数组
        message - 异常消息
      • isEmpty

        public static <T> void isEmpty​(T[] array,
                                       Code code)
        检查给定数组是否为空
        Parameters:
        array - 数组
        code - 错误码
      • notEmpty

        public static <T> void notEmpty​(T[] array,
                                        String message)
        检查给定数组是否非空
        Parameters:
        array - 数组
        message - 异常消息
      • notEmpty

        public static <T> void notEmpty​(T[] array,
                                        Code code)
        检查给定数组是否非空
        Parameters:
        array - 数组
        code - 错误码
      • isEmpty

        public static <T> void isEmpty​(Collection<T> collection,
                                       String message)
        检查给定集合是否为空
        Parameters:
        collection - 集合
        message - 异常消息
      • isEmpty

        public static <T> void isEmpty​(Collection<T> collection,
                                       Code code)
        检查给定集合是否为空
        Parameters:
        collection - 集合
        code - 错误码
      • notEmpty

        public static <T> void notEmpty​(Collection<T> collection,
                                        String message)
        检查给定集合是否非空
        Parameters:
        collection - 集合
        message - 异常消息
      • notEmpty

        public static <T> void notEmpty​(Collection<T> collection,
                                        Code code)
        检查给定集合是否非空
        Parameters:
        collection - 集合
        code - 错误码