@NotNull: Checks whether the value is not null, disregarding the content
@NotEmpty: Checks whether the value is not null nor empty. If it has just empty spaces, it will allow it as not empty.
@NotBlank: Checks whether the value is not null nor empty, trimming the value first. It means that, it won’t allow just empty spaces.
Here are a few examples:
String name = null;
@NotNull
: false@NotEmpty
: false@NotBlank
: falseString name = "";
@NotNull
:true@NotEmpty
: false@NotBlank
: falseString name = " ";
@NotNull
:true@NotEmpty
:true@NotBlank
: falseString name = "Great answer!";
@NotNull
:true@NotEmpty
:true@NotBlank
:true