I need to validate mandatory fields in my class
For example, 9
fields must not be null
.
I need to check if they are all null but I
You can use javax.validator
and hibernate.validator
with @NotNull
annotation on each field (or whichever field you want) on your excess
POJO class. This combination provides an extensive pattern checking as well.
By this you don't have to do all the if checks explicitly. You can get ride of not only null checks but also pattern matching checks which can get scattered all over your code.