类 Assert


  • public class Assert
    extends cn.hutool.core.lang.Assert
    RESTful断言
    从以下版本开始:
    2022/7/22
    作者:
    ylyue
    • 构造器概要

      构造器 
      构造器 说明
      Assert()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static void notThrow​(String throwMsg, Runnable lambdaRun)
      断言-执行给定代码块不会抛出异常
      static void notThrowIfErrorPrintMsg​(String printMsg, Runnable lambdaRun)
      断言-执行给定代码块不会抛出异常
      static void notThrowIfErrorPrintStackTrace​(String printMsg, Runnable lambdaRun)
      断言-执行给定代码块不会抛出异常
      • 从类继承的方法 cn.hutool.core.lang.Assert

        checkBetween, checkBetween, checkBetween, checkBetween, checkBetween, checkBetween, checkBetween, checkBetween, checkBetween, checkBetween, checkIndex, checkIndex, isAssignable, isAssignable, isFalse, isFalse, isFalse, isInstanceOf, isInstanceOf, isNull, isNull, isNull, isTrue, isTrue, isTrue, noNullElements, noNullElements, noNullElements, notBlank, notBlank, notBlank, notContain, notContain, notContain, notEmpty, notEmpty, notEmpty, notEmpty, notEmpty, notEmpty, notNull, notNull, notNull, state, state, state
    • 构造器详细资料

      • Assert

        public Assert()
    • 方法详细资料

      • notThrow

        public static void notThrow​(String throwMsg,
                                    Runnable lambdaRun)
        断言-执行给定代码块不会抛出异常

        若不是期望的结果,执行代码块时出现错误,将抛出ResultException

        参数:
        throwMsg - 执行代码块错误时抛出的ResultException message
        lambdaRun - lambda给定代码块,示例:() -> {代码块}
      • notThrowIfErrorPrintMsg

        public static void notThrowIfErrorPrintMsg​(String printMsg,
                                                   Runnable lambdaRun)
        断言-执行给定代码块不会抛出异常

        若不是期望的结果,执行代码块时出现错误,将打印printMsg

        参数:
        printMsg - 执行代码块错误时,打印的信息
        lambdaRun - lambda给定代码块,示例:() -> {代码块}
      • notThrowIfErrorPrintStackTrace

        public static void notThrowIfErrorPrintStackTrace​(String printMsg,
                                                          Runnable lambdaRun)
        断言-执行给定代码块不会抛出异常

        若不是期望的结果,执行代码块时出现错误,将打印printMsg与堆栈跟踪信息

        参数:
        printMsg - 执行代码块错误时,打印的信息
        lambdaRun - lambda给定代码块,示例:() -> {代码块}