Examples for Lombok good practices and common pitfalls.
- JDK 8
- Gradle or IDE Gradle support
- Lombok plugin over your IDE
- Side-effects possible using
@RequiredArgsConstructor
and@AllArgsConstructor
generated constructors over mutable fields. - Null initialization using
@NoArgsConstructor
- Symmetry of
equals
method broken when not all classes in hierarchy use@EqualsAndHashCode
- Multiple ways of accessing object state when using
@Getter/@Setter
over non-private fields.
- Actual field reference returned using
@Getter
. Side-effects possible when field type is mutable.
- Actual parameter reference set using
@Setter
. Side-effects possible when field type is mutable.
- Actual field reference returned using
@Value
. Side-effects possible when field type is mutable. - Actual parameter reference set using
@Value
. Side-effects possible when field type is mutable.
💥 All tests in ro.stancalau.examples.pitfalls
package are meant to fail in order to exemplify common pitfalls.