util
@Builder was introduced as experimental feature in lombok v0
The singular annotation is used together with @Builder to create single element 'add' methods in the builder for collections
Whatever the use case, it all starts with a @Singular annotation above your list or map: This enables you to use chains of single element inserts to your collection: In that case, secrets is a map Using @Singular with @Builder generated singular methods for collection parameters/fields in the auto-generated class
Name of the builder class
On the Builder documentation page it says:
Default | @Singular | Complete Tutorial | Java | Junit5 | Project Lombok Complete Tutorial #ProjectLombok #Java #Tutorial
In this article, we’ll discuss Lombok’s @Builder annotation, which implements the builder design pattern for us
@Singular @Builder를 사용하여 달달하게 코딩을 하던 도중 팀원이 @Singular라는 좋은 물건을 가지고 왔다
do nothing
We are considering different approaches and discuss these regularly ourselves
I have the following table class which makes usage of @Builder Lombok annotation with a custom builder class: @Builder public class MyTable { public static class MyTableBuilder { public void entry (final MyEntry myEntry) { } } } In another class that is composed by MyTable I would like to make usage of @Builder + @Singular Here's a list of things you can try: Validate that the desired Lombok dependency appears in the central repository
Using @Builder on a Class
If a class is annotated, then a package-private constructor is generated with all fields as arguments (as if
Having following class definition @Value @Builder(toBuilder = true) public class ValueObject{ @Singular(value = "value") private List
It’s simple and readable
@SuperBuilder generates a protected constructor on the class that takes a builder instance as a parameter
In that case, it's as if you annotate all the non-static fields in that class with the annotation
Value; @Builder @Value public class Car { private String carName; @Singular ("part") private List
Obviously the other option is to write my own builder which does all these checks
Similar to the issue mentioned below google/error-prone#2575 Further investigation reveal that bug pattern "FallThrough" for lombok annotations (like @Singular) could be a false positive, because Lombok modifies the AST on the fly causing trouble to errorprone checks, as mentioned in below issue and PR
So it will be null instead of an empty Collection
16
Builder
My class look like: @Builder @Data class A{ @Singular private final List