@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:

  1. String name = null;
    @NotNull: false
    @NotEmpty: false
    @NotBlank: false

  2. String name = "";
    @NotNull:true
    @NotEmpty: false
    @NotBlank: false

  3. String name = " ";
    @NotNull:true
    @NotEmpty:true
    @NotBlank: false

  4. String name = "Great answer!";
    @NotNull:true
    @NotEmpty:true
    @NotBlank:true

results matching ""

    No results matching ""