From the course: Learning Lombok: Streamlined Java Programming

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Simplifying null checks and removing bloat

Simplifying null checks and removing bloat - Spring Tutorial

From the course: Learning Lombok: Streamlined Java Programming

Simplifying null checks and removing bloat

- Having 0 2 0 2 begin, lombok demo open in IntelliJ. Let's investigate how we might force null checks on our employee entity. Looking at our employee entity class we might have a database table constraint on various columns, so as to ensure that certain fields are non-null. It makes sense to apply these constraints to fields like the last name and the first name. Lombok offers the non-null annotation that actually will force null checking on our fields. Please keep in mind that lombok's non-null is different than the Jakarta validation constraints version or the fine bugs implementation. Those variants are strictly concerned with validation and require third party APIs or custom code to check the validity of the fields. Let's go ahead and apply the non-null to the last name, to the first name and to our employee status. Then click the build button. Once the build is complete go to the project folder, then the build…

Contents