Şu satırı dahil ederiz
import lombok.Singular;
Açıklaması şöyle
ÖrnekWhen the @Singular annotation is placed on a collection property, Lombok creates special builder methods to individually add items to that collection, rather than adding the entire collection at once. This is particularly nice for tests as creating small collections in Java is not concise.
Şöyle yaparız
@Value@Builder(toBuilder = true)public class User {@NonNullUUID userId;@NonNullString email;@SingularSet<String> favoriteFoods;@NonNull@Builder.DefaultString avatar = “default.png”;}User user = User.builder().userId(UUID.random()).email(“grubhub@grubhub.com”).favoriteFood(“burritos”).favoriteFood(“dosas”).build()
Hiç yorum yok:
Yorum Gönder