概念
Assert翻譯為中文為"斷言",就是斷定某一個實際的值就為自己預期想得到的,如果不一樣就拋出異常。
方法及作用
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指定的類