Assert翻譯爲中文爲"斷言",就是判定某一個實際的值就爲本身預期想獲得的,若是不同就拋出異常。ui
Assert.notNull(Object object,"object is required"); // 對象非空 Assert.isTrue(Object object,"object must be true"); // 對象必須爲true Assert.notEmpty(Collection collection,"collection must not be empty"); // 集合不能爲空 Assert.hasLength(String text,"text must be specified"); // 字符不爲null且字符長度不爲0 Assert.hasText(String text,"text must not be empty"); // text不爲null且必須至少包含一個非空的字符 Assert.isInstanceOf(Class class, Object object,"class must be of type[class]"); // object必須爲class指定的類