Last active
February 25, 2025 04:10
-
-
Save kjivan/a34311e206ce0e3a3e2b5e3f8f594517 to your computer and use it in GitHub Desktop.
Revisions
-
kjivan revised this gist
Feb 25, 2025 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,5 +21,6 @@ * This makes them required cuasing them to be included in the constructor and therefore [injection](https://www.baeldung.com/constructor-injection-in-spring) * Make [`@Value`](https://www.baeldung.com/spring-value-annotation) class variables `private` * These values are not constuctor injected * Do not use [`@Data`](https://projectlombok.org/features/Data) , [`@Getter`](https://projectlombok.org/features/GetterSetter) , [`@Setter`](https://projectlombok.org/features/GetterSetter) * data in services should not be used by anyone else * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 25, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * Do not use [`@Data`](https://projectlombok.org/features/Data) and [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode) * Use [`@Getter`](https://projectlombok.org/features/GetterSetter) and [`@Setter`](https://projectlombok.org/features/GetterSetter) * Don't forget to exclude lazy attributes if you use [`@ToString`](https://projectlombok.org/features/ToString) * Don't forget to add [`@NoArgsConstructor`](https://projectlombok.org/features/constructor) if you use [`@Builder`](https://projectlombok.org/features/Builder) or [`@AllArgsConstructor`](https://projectlombok.org/features/constructor) or [`@RequiredArgsConstructor`](https://projectlombok.org/features/constructor) * Explanation for rules above: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) * Use [`@Builder`](https://projectlombok.org/features/Builder) if setting lots of different fields -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,18 @@ # Lombok Best Practices ## Entities * Do not use [`@Data`](https://projectlombok.org/features/Data) and [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode) * Use [`@Getter`](https://projectlombok.org/features/GetterSetter) and [`@Setter`](https://projectlombok.org/features/GetterSetter) * Don't forget to exclude lazy attributes if you use [`@ToString`](https://projectlombok.org/features/ToString) * Don't forget to add [`@NoArgsConstructor`](https://projectlombok.org/features/constructor) if you use [`@Builder`](https://projectlombok.org/features/Builder) or [`@FullArgsConstructor`](https://projectlombok.org/features/constructor) or [`@RequiredArgsConstructor`](https://projectlombok.org/features/constructor) * Explanation for rules above: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) * Use [`@Builder`](https://projectlombok.org/features/Builder) if setting lots of different fields ## DTOs/POJOs/Classes with just member variables to store data * Use [`@Data`](https://projectlombok.org/features/Data) * Most pojos can benefit from all the features of [`@Data`](https://projectlombok.org/features/Data) with no notable side effects * [`@Data`](https://projectlombok.org/features/Data) is a convenient shortcut annotation that bundles the features of [`@ToString`](https://projectlombok.org/features/ToString), [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode), [`@Getter`](https://projectlombok.org/features/GetterSetter) / [`@Setter`](https://projectlombok.org/features/GetterSetter) * Use [`@Builder`](https://projectlombok.org/features/Builder) if setting lots of different fields * [Explanation of DTOs,POJOs](https://www.baeldung.com/java-pojo-javabeans-dto-vo) ## Services @@ -21,5 +21,5 @@ * This makes them required cuasing them to be included in the constructor and therefore [injection](https://www.baeldung.com/constructor-injection-in-spring) * Make [`@Value`](https://www.baeldung.com/spring-value-annotation) class variables `private` * These values are not constuctor injected * Do not use [`@Data`](https://projectlombok.org/features/Data) , [`@Getter`](https://projectlombok.org/features/GetterSetter) , [`@Setter`](https://projectlombok.org/features/GetterSetter) data in services should not be used by anyone else * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,12 +6,13 @@ * Use [`@Getter`](https://projectlombok.org/features/GetterSetter) and [`@Setter`](https://projectlombok.org/features/GetterSetter) * Don't forget to add [`@NoArgsConstructor`](https://projectlombok.org/features/constructor) if you use [`@Builder`](https://projectlombok.org/features/Builder) or [`@FullArgsConstructor`](https://projectlombok.org/features/constructor) or [`@RequiredArgsConstructor`](https://projectlombok.org/features/constructor) * Explanation for rules above: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) * Add [`@Builder`](https://projectlombok.org/features/Builder) if setting lots of different fields ## DTOs/POJOs/Classes with just member variables to store data * Use [`@Data`](https://projectlombok.org/features/Data) * Most pojos can benefit from all the features of [`@Data`](https://projectlombok.org/features/Data) with no notable side effects * [`@Data`](https://projectlombok.org/features/Data) is a convenient shortcut annotation that bundles the features of [`@ToString`](https://projectlombok.org/features/ToString), [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode), [`@Getter`](https://projectlombok.org/features/GetterSetter) / [`@Setter`](https://projectlombok.org/features/GetterSetter) * Add [`@Builder`](https://projectlombok.org/features/Builder) if setting lots of different fields * [Explanation of DTOs,POJOs](https://www.baeldung.com/java-pojo-javabeans-dto-vo) ## Services -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ * This makes them required cuasing them to be included in the constructor and therefore [injection](https://www.baeldung.com/constructor-injection-in-spring) * Make [`@Value`](https://www.baeldung.com/spring-value-annotation) class variables `private` * These values are not constuctor injected * Don't use [`@Data`](https://projectlombok.org/features/Data) , [`@Getter`](https://projectlombok.org/features/GetterSetter) , [`@Setter`](https://projectlombok.org/features/GetterSetter) data in services should not be used by anyone else * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ * This makes them required cuasing them to be included in the constructor and therefore [injection](https://www.baeldung.com/constructor-injection-in-spring) * Make [`@Value`](https://www.baeldung.com/spring-value-annotation) class variables `private` * These values are not constuctor injected * Don't use [`@Data`](https://projectlombok.org/features/Data) , [`@Getter`](https://projectlombok.org/features/GetterSetter) , [`@Setter`](https://projectlombok.org/features/GetterSetter) data in service should not be used by anyone else * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,21 +4,21 @@ * Should not use [`@Data`](https://projectlombok.org/features/Data) and [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode) * If you use [`@ToString`](https://projectlombok.org/features/ToString) don't forget to exclude lazy attributes * Use [`@Getter`](https://projectlombok.org/features/GetterSetter) and [`@Setter`](https://projectlombok.org/features/GetterSetter) * Don't forget to add [`@NoArgsConstructor`](https://projectlombok.org/features/constructor) if you use [`@Builder`](https://projectlombok.org/features/Builder) or [`@FullArgsConstructor`](https://projectlombok.org/features/constructor) or [`@RequiredArgsConstructor`](https://projectlombok.org/features/constructor) * Explanation for rules above: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) ## DTOs/POJOs/Classes with just member variables to store data * Use [`@Data`](https://projectlombok.org/features/Data) * Most pojos can benefit from all the features of [`@Data`](https://projectlombok.org/features/Data) with no notable side effects * [`@Data`](https://projectlombok.org/features/Data) is a convenient shortcut annotation that bundles the features of [`@ToString`](https://projectlombok.org/features/ToString), [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode), [`@Getter`](https://projectlombok.org/features/GetterSetter) / [`@Setter`](https://projectlombok.org/features/GetterSetter) * Add [`@Builder`](https://projectlombok.org/features/Builder) * [Explanation of DTOs,POJOs](https://www.baeldung.com/java-pojo-javabeans-dto-vo) ## Services * Use [`@RequiredArgsConstructor`](https://projectlombok.org/features/constructor) * Make dependency injected class variables `private final` * This makes them required cuasing them to be included in the constructor and therefore [injection](https://www.baeldung.com/constructor-injection-in-spring) * Make [`@Value`](https://www.baeldung.com/spring-value-annotation) class variables `private` * These values are not constuctor injected * Don't use [`@Data`](https://projectlombok.org/features/Data) , [`@Getter`](https://projectlombok.org/features/GetterSetter) , [`@Setter`](https://projectlombok.org/features/GetterSetter) data in services should be private * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 13 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,20 +1,24 @@ # Lombok Best Practices ## Entities * Should not use [`@Data`](https://projectlombok.org/features/Data) and [`@EqualsAndHashCode`](https://projectlombok.org/features/EqualsAndHashCode) * If you use [`@ToString`](https://projectlombok.org/features/ToString) don't forget to exclude lazy attributes * Use [`@Getter`](https://projectlombok.org/features/GetterSetter) and [`@Setter`](https://projectlombok.org/features/GetterSetter) * Don't forget to add [`@NoArgsConstructor`](https://projectlombok.org/features/NoArgsConstructor) if you use [`@Builder`](https://projectlombok.org/features/Builder) or [`@FullArgsConstructor`](https://projectlombok.org/features/FullArgsConstructor) or [`@RequiredArgsConstructor`](https://projectlombok.org/features/RequiredArgsConstructor) * Explanation for rules above: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) ## DTOs/POJOs/Classes with just member variables to store data * Use [`@Data`](https://projectlombok.org/features/Data) * Most pojos can benefit from all the features of [`@Data`](https://projectlombok.org/features/Data) with no notable side effects * [`@Data`](https://projectlombok.org/features/Data) is a convenient shortcut annotation that bundles the features of @ToString, @EqualsAndHashCode, @Getter / @Setter * Add [`@Builder`](https://projectlombok.org/features/Builder) * [Explanation of DTOs,POJOs](https://www.baeldung.com/java-pojo-javabeans-dto-vo) ## Services * Use `@RequiredArgsConstructor` * Make dependency injected class variables `private final` * This makes them required and therefore will be included in the constructor and therefore [injected](https://www.baeldung.com/constructor-injection-in-spring) * Make `@Value` class variables `private` * These values are not constuctor injected * Don't use `@Data` , `@Getter` , `@Setter` data in services should be private * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,8 @@ ## Services * Use `@RequiredArgsConstructor` * Make dependency injected values `private final` * This will force the generated constructor to use them * Make `@Value` values `private` * These are not injected via a constructor so they shouldn't be included * Don't use `@Data` , `@Getter` , `@Setter` data in services should be private * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 14, 2024 . No changes.There are no files selected for viewing
-
kjivan revised this gist
Feb 14, 2024 . 1 changed file with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,15 @@ * Should not use `@Data` and `@EqualsAndHashCode` * If you use `@ToString` don't forget to exclude lazy attributes * Use `@Getter` and `@Setter` * Don't forget to add `@NoArgsConstructor` if you use `@Builder` or `@FullArgsConstructor` or `@RequiredArgsConstructor` * Explanation for rules above: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) ## DTOs/POJOs/Classes with just member variables to store data * Use `@Data` ## Services * Use `@RequiredArgsConstructor` * Make dependency injected values `private final` * Make `@Value` values `private` * Don't use `@Data` , `@Getter` , `@Setter` data in services should be private * For testing use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) -
kjivan revised this gist
Feb 12, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ * Should not use `@Data` and `@EqualsAndHashCode` * If you use `@ToString` don't forget to exclude lazy attributes * Use `@Getter` and `@Setter` * Don't forget to add `@NoArgsConstructor` if you use `@Builder` or `@RequiredArgsConstructor` or `@FullArgsConstructor` * Reference: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) ## DTOs/POJOs/Classes with just member variables to store data -
kjivan revised this gist
Jan 23, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ # Lombok Best Practices ## Entities * Should not use `@Data` and `@EqualsAndHashCode` -
kjivan created this gist
Jan 23, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # Lombok Best Practices # Lombok Best Practices ## Entities * Should not use `@Data` and `@EqualsAndHashCode` * If you use `@ToString` don't forget to exclude lazy attributes * Use `@Getter` and `@Setter` * Don't forget to add `@NoArgsConstructor` if you use `@Builder` or `@NoArgsConstructor` * Reference: [Lombok and JPA: What may go wrong?](https://jpa-buddy.com/blog/lombok-and-jpa-what-may-go-wrong/) ## DTOs/POJOs/Classes with just member variables to store data * Use `@Data` ## Services * Generally don't use `@Data` , `@Getter` , `@Setter` most of the data in services should be private ** For tests use [ReflectionTestUtils](https://www.baeldung.com/spring-reflection-test-utils) * Use `@RequiredArgsConstructor` ** Make dependency injected values `private final` ** Make `@Value` values `private`