字符串判断是否为空
hasText
hasLength
notNull
notEmpty
notNull or notEnoty
字符串判断是否为空
hasText
String a = "";
String b = " ";
String c = null;
String d = "haha";
Assert.hasText(a,"a is null");//a is null
Assert.hasText(b,"b is null");//b is null
Assert.hasText(c,"c is null");//c is null
Assert.hasText(c,"d is null");//true
hasLength
String a = "";
String b = " ";
String c = null;
Assert.hasLength(a,"a is null");//a is null
Assert.hasLength(b,"a is null");//true
Assert.hasLength(c,"a is null");//c is null
notNull
String a = "";
String b = " ";
String c = null;
Assert.notNull(a,"a is null");//true
Assert.notNull(b,"b is null");//true
Assert.notNull(c,"c is null");//c is null
notEmpty
ArrayList<Object> a = new ArrayList<>();
ArrayList<Object> b = new ArrayList<>();
b.add(123);
Assert.notEmpty(a,"a not empty");//a is empty
Assert.notEmpty(b,"b not empty");//true
notNull or notEnoty
@Test
public void test() {
String ab[] = new String[]{"a"};
org.springframework.util.Assert.notEmpty(ab,"ab不能为空");
String ac[] = new String[]{};
org.springframework.util.Assert.notEmpty(ac,"ac不能为空");
}