@NotNull
@NotNull is a variable level annotation used to specifies that that the variable must not be null
String name=null; --> returns false
name=""; --> returns true
name=" "-> return true
is applicable for char, string, collections and arrays
@NotEmpty
@NotEmpty is a variable level annotation used to specify that value must not be null and not be empty that means size must be greater than zero
is applicable for char, string, collections and arrays
@NotBlank
@NotBlank is variable level annotation applicable only for String where variable not to be null and length must be more than zero.
@NotNull
|
@NotEmpty
|
@NotBlank
| |
Char
|
Yes
|
Yes
|
Yes
|
String
|
Yes
|
Yes
|
Yes
|
Collections
|
Yes
|
Yes
|
No
|
Arrays
|
Yes
|
Yes
|
No
|
Size > 0
|
May be empty
|
Yes
|
Yes
|
Empty
|
allowed
|
Not allowed
|
Not allowed
|
differnces between null and emtpy
String name=null; -> this is null
String name=""; -> not null but empty
Post a Comment
Post a Comment