zoukankan      html  css  js  c++  java
  • 关于断言机制(Assert)常用的方法

    (1) isTrue(boolean expression)
         isTrue(boolean expression, String message)
                   当 expression 不为 true 抛出异常;
    (2)notNull(Object object)
                   当 object 不为 null 时抛出异常,notNull(Object object, String message) 方法允许您通过 message 定制异常信息。和 notNull() 方法断言规则相反的方法是 isNull(Object object)/isNull(Object object, String message),它要求入参一定是 null;
    (3)notEmpty(Collection collection)
        notEmpty(Collection collection, String message)
                   当集合未包含元素时抛出异常。
     
       notEmpty(Map map)
       notEmpty(Map map, String message)
       notEmpty(Object[] array, String message)
       notEmpty(Object[] array, String message)
                 分别对 Map 和 Object[] 类型的入参进行判断;
    (4)hasLength(String text)
        hasLength(String text, String message)
                 当 text 为 null 或长度为 0 时抛出异常
    (5)hasText(String text)
        hasText(String text, String message)
                  text 不能为 null 且必须至少包含一个非空格的字符,否则抛出异常;
    (6)isInstanceOf(Class clazz, Object obj)
        isInstanceOf(Class type, Object obj, String message)
                 如果 obj 不能被正确造型为 clazz 指定的类将抛出异常;
    (7)isAssignable(Class superType, Class subType)
    isAssignable(Class superType, Class subType, String message)
                subType 必须可以按类型匹配于 superType,否则将抛出异常;
  • 相关阅读:
    NSRunLoop 详解
    Delphi经验总结(2)
    Delphi经验总结(3)
    卸载Windows服务
    Windows 8操作技巧之快捷键大全
    delphi 换行操作 Word
    现在, Delphi 的多线程已经非常易用了!
    XP 之后, Delphi 动注册表不方便了...逼出来一个办法:
    写了一个字符串的二维表: TSta
    现在使用控件, 更喜欢继承
  • 原文地址:https://www.cnblogs.com/jbml-154312/p/7299902.html
Copyright © 2011-2022 走看看