字符串、集合等为空判定

import org.springframework.util.Assert;
Assert工具类的使用

notNull(Object object, "object is required") - 对象非空 3hf
isTrue(Object object, "object must be true") - 对象必须为true
notEmpty(Collection collection, "collection must not be empty") - 集合非空
hasLength(String text, "text must be specified") - 字符不为null且字符长度不为0
hasText(String text, "text must not be empty") - text 不为null且必须至少包含一个非空格的字符
isInstanceOf(Class clazz, Object obj, "clazz must be of type [clazz]") - obj必须能被正确造型成为clazz 指定的类





 

posted @ 2020-11-10 10:22  五更琉璃V  阅读(166)  评论(0编辑  收藏  举报