@ NotEmpty, @ NotBlank, @ NotNull, @ notempty @ notblank
@ NotEmpty used on the Collection class
@ NotBlank: Used on String
@ NotNull is used in basic types
Only simple results, but more specific content cannot be found, so I went to the source code and found the following annotations:
1. @ NotEmpty
/**
* Asserts that the annotated string, collection, map or array is not {@code null} or empty.
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
That is to say, the String class, Collection, Map, and array added with @ NotEmpty cannot be null or the length is 0 (the isEmpty () method of String, Collection, and Map ).
2. @ NotBlank
/**
* Validate that the annotated string is not {@code null} or empty.
* The difference to {@code NotEmpty} is that trailing whitespaces are getting ignored.
*
* @author Hardy Ferentschik
*/
"The difference to {@ code NotEmpty} is that trailing whitespaces are getting ignored. "-> unlike {@ code NotEmpty}, trailing spaces are ignored. That is, strings with pure spaces do not comply with the rules. So it is said that @ NotBlank is used for String.
3. @ NotNull
/**
* The annotated element must not be {@code null}.
* Accepts any type.
*
* @author Emmanuel Bernard
*/
This is easy to understand and cannot be null.