DEV Community

Discussion on: Effective Java! Check Parameters for Validity

Collapse
 
kylec32 profile image
Kyle Carter

Yeah Lombok is a great way to generate the nonnull checks. I actually don't find myself using it much but I like the idea. I'm not sure I know of other validity checks it can do for you other than nonnull but that check is definitely a common one.

As for testing I would say go ahead and test it. The test shows that it's important and elevates the verification logic to the same importance as other business logic. These validity checks are often very simple so messing up the implementation is not as likely but I do think it can protect against regressions where maybe a future developer imports one of the other Nonnull annotations that behaves different than we were expecting.