Help with Lombok

I am making utility methods for sending discord webhooks. my goal is this:
DiscordWebhook webhook = DiscordWebhook.builder()
.webhookURI(new URI("https://discord.com/api/webhooks/123"))
.content("hello this is content")
.username("person")
.avatar(new URI("https://cdn.discordapp.com/attachments/123"))
.addEmbed(
DiscordEmbed.builder()
.hex("#FF0000")
.title("embed title")
.description("embed description")
.build()
)
.build();
DiscordWebhook webhook = DiscordWebhook.builder()
.webhookURI(new URI("https://discord.com/api/webhooks/123"))
.content("hello this is content")
.username("person")
.avatar(new URI("https://cdn.discordapp.com/attachments/123"))
.addEmbed(
DiscordEmbed.builder()
.hex("#FF0000")
.title("embed title")
.description("embed description")
.build()
)
.build();
everything works, except for the addEmbed part my class is defined like this:
@Builder
@Getter
@ToString
public class DiscordWebhook {

private static final HttpClient httpClient = HttpClient.newBuilder().build();

private final URI webhookURI;
private final String username;
private final String content;
private final URI avatar;
private final List<DiscordEmbed> embeds = new ArrayList<>(10);

public void addEmbed(DiscordEmbed embed) { // this was a test which didnt work since the method shouldve been inside the builder class (but lombok generates that so i cant edit it)
this.embeds.add(embed);
}

...
@Builder
@Getter
@ToString
public class DiscordWebhook {

private static final HttpClient httpClient = HttpClient.newBuilder().build();

private final URI webhookURI;
private final String username;
private final String content;
private final URI avatar;
private final List<DiscordEmbed> embeds = new ArrayList<>(10);

public void addEmbed(DiscordEmbed embed) { // this was a test which didnt work since the method shouldve been inside the builder class (but lombok generates that so i cant edit it)
this.embeds.add(embed);
}

...
so how do i make an embed adder?
5 Replies
JavaBot
JavaBot5mo ago
This post has been reserved for your question.
Hey @eren.! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
tjoener
tjoener5mo ago
Add @Singular To the List property Also, you might want @Value? Or just use records
eren.
eren.OP5mo ago
"not applicable to this field" i added singular and now what? i dont have any new methods or anything im new to lombok oh i just needed to remove = new ArrayList<>(10) thanks anyway
JavaBot
JavaBot5mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
JavaBot
JavaBot5mo ago
Post Closed
This post has been closed by <@587604022349791274>.
Want results from more Discord servers?
Add your server