Records Are Here! Can We Remove Lombok Already?
In this article, we’ll discuss Java 17’s records and see if we can leverage the new keyword to completely replace the usage of Lombok.
1. Records vs Lombok’s @Value
Lombok offers the @Value annotation to help us generate immutable “value objects”. Even though this can come in handy in some situations, I rarely saw this feature used.
For instance, the following code snippet will generate an immutable FullName class:
Though, we can further simplify this declaration by using Java 17’s new feature, the record keyword:
The two solutions will have the same result. In this case, it will be simpler to use the language feature rather than some external library.