From 68ceb6e2bf760b5a407d026c810d87cbf79f47f8 Mon Sep 17 00:00:00 2001 From: Andre_601 <11576465+Andre601@users.noreply.github.com> Date: Tue, 8 Jun 2021 17:29:13 +0200 Subject: [PATCH] Add missing Collection overload (#5) --- .../jdautilities/menu/EmbedPaginator.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/menu/src/main/java/com/jagrosh/jdautilities/menu/EmbedPaginator.java b/menu/src/main/java/com/jagrosh/jdautilities/menu/EmbedPaginator.java index 15b344d5..f2e80e05 100644 --- a/menu/src/main/java/com/jagrosh/jdautilities/menu/EmbedPaginator.java +++ b/menu/src/main/java/com/jagrosh/jdautilities/menu/EmbedPaginator.java @@ -26,10 +26,7 @@ import net.dv8tion.jda.api.requests.RestAction; import net.dv8tion.jda.internal.utils.Checks; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; +import java.util.*; import java.util.concurrent.TimeUnit; import java.util.function.BiFunction; import java.util.function.Consumer; @@ -453,6 +450,21 @@ public Builder addItems(MessageEmbed... embeds) this.embeds.addAll(Arrays.asList(embeds)); return this; } + + /** + * Adds the collection of provided {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds} to the list + * of items to paginate. + * + * @param embeds + * The collection of MessageEmbeds to add + * + * @return This builder + */ + public Builder addItems(Collection embeds) + { + this.embeds.addAll(embeds); + return this; + } /** * Adds {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds} to the list of items to paginate. @@ -494,6 +506,22 @@ public Builder setItems(MessageEmbed... embeds) return this; } + /** + * Sets the {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds} to paginate. + *
This method clears all previously set items before adding the provided collection of MessageEmbeds. + * + * @param embeds + * The collection of MessageEmbeds to set. + * + * @return This builder + */ + public Builder setItems(Collection embeds) + { + this.embeds.clear(); + addItems(embeds); + return this; + } + /** * Sets the {@link net.dv8tion.jda.api.entities.MessageEmbed MessageEmbeds} to paginate. *
This method clears all previously set items before setting each String as a new MessageEmbed.