public class WebhookCluster
extends java.lang.Object
implements java.lang.AutoCloseable
Webhook created by the cluster through buildWebhook(long, String)
are initialized with defaults specified by
| Modifier and Type | Field and Description |
|---|---|
protected AllowedMentions |
allowedMentions |
protected okhttp3.OkHttpClient |
defaultHttpClient |
protected java.util.concurrent.ScheduledExecutorService |
defaultPool |
protected boolean |
isDaemon |
protected java.util.concurrent.ThreadFactory |
threadFactory |
protected java.util.List<WebhookClient> |
webhooks |
| Constructor and Description |
|---|
WebhookCluster()
Default initializes a new WebhookCluster.
|
WebhookCluster(@NotNull java.util.Collection<? extends WebhookClient> initialClients)
Creates a new WebhookCluster with the provided clients
|
WebhookCluster(int initialCapacity)
Creates a webhook cluster with the specified capacity.
|
| Modifier and Type | Method and Description |
|---|---|
@NotNull WebhookCluster |
addWebhooks(@NotNull java.util.Collection<WebhookClient> clients)
Adds the provided webhooks to the cluster.
|
@NotNull WebhookCluster |
addWebhooks(WebhookClient... clients)
Adds the provided webhooks to the cluster.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull java.util.Collection<WebhookEmbed> embeds)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull java.io.File file)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull java.lang.String content)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull java.lang.String fileName,
@NotNull byte[] data)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull java.lang.String fileName,
@NotNull java.io.File file)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull java.lang.String fileName,
@NotNull java.io.InputStream data)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull WebhookEmbed first,
WebhookEmbed... embeds)
Sends a message to all registered clients.
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
broadcast(@NotNull WebhookMessage message)
Sends a message to all registered clients.
|
@NotNull WebhookCluster |
buildWebhook(long id,
@NotNull java.lang.String token)
Builds a
WebhookClient instance with the provided
components and specified default configurations. |
void |
close()
Performs cascade closing on current webhook clients,
all clients will be closed and removed after this returns.
|
@NotNull java.util.List<WebhookClient> |
closeIf(@NotNull java.util.function.Predicate<WebhookClient> predicate)
Closes and removes webhook clients based on the specified filter.
|
@NotNull java.util.List<WebhookClient> |
getWebhooks()
Unmodifiable list of currently registered clients
|
@NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> |
multicast(@NotNull java.util.function.Predicate<WebhookClient> filter,
@NotNull WebhookMessage message)
Sends a message to a filtered set of clients.
|
@NotNull WebhookClientBuilder |
newBuilder(long id,
@NotNull java.lang.String token)
Creates a
WebhookClientBuilder instance with the provided
components and specified default configurations. |
@NotNull java.util.List<WebhookClient> |
removeIf(@NotNull java.util.function.Predicate<WebhookClient> predicate)
Removes webhooks from the cluster based on the specified filter.
|
@NotNull WebhookCluster |
removeWebhooks(@NotNull java.util.Collection<WebhookClient> clients)
Removes the provided webhooks from the cluster.
|
@NotNull WebhookCluster |
removeWebhooks(WebhookClient... clients)
Removes the provided webhooks from the cluster.
|
@NotNull WebhookCluster |
setAllowedMentions(@Nullable AllowedMentions allowedMentions)
The mention whitelist to use by default for every webhook client.
|
@NotNull WebhookCluster |
setDefaultDaemon(boolean isDaemon)
Configures whether
WebhookClient instances should be daemon by default. |
@NotNull WebhookCluster |
setDefaultExecutorService(@Nullable java.util.concurrent.ScheduledExecutorService executorService)
Configures the default executor service that will be used to build
WebhookClient instances. |
@NotNull WebhookCluster |
setDefaultHttpClient(@Nullable okhttp3.OkHttpClient defaultHttpClient)
Configures the default http client that will be used to build
WebhookClient instances. |
@NotNull WebhookCluster |
setDefaultThreadFactory(@Nullable java.util.concurrent.ThreadFactory factory)
Configures the default thread factory that will be used to build
WebhookClient instances. |
protected final java.util.List<WebhookClient> webhooks
protected okhttp3.OkHttpClient defaultHttpClient
protected java.util.concurrent.ScheduledExecutorService defaultPool
protected java.util.concurrent.ThreadFactory threadFactory
protected AllowedMentions allowedMentions
protected boolean isDaemon
public WebhookCluster(@NotNull
@NotNull java.util.Collection<? extends WebhookClient> initialClients)
initialClients - Clients to add to the clusterjava.lang.NullPointerException - If provided with nullpublic WebhookCluster(int initialCapacity)
initialCapacity - The initial capacityjava.lang.IllegalArgumentException - If the capacity is illegalArrayList.ArrayList(int)public WebhookCluster()
@NotNull public @NotNull WebhookCluster setDefaultHttpClient(@Nullable @Nullable okhttp3.OkHttpClient defaultHttpClient)
WebhookClient instances.defaultHttpClient - The default http clientWebhookClientBuilder.setHttpClient(okhttp3.OkHttpClient)@NotNull public @NotNull WebhookCluster setDefaultExecutorService(@Nullable @Nullable java.util.concurrent.ScheduledExecutorService executorService)
WebhookClient instances.executorService - The default executor serviceWebhookClientBuilder.setExecutorService(java.util.concurrent.ScheduledExecutorService)@NotNull public @NotNull WebhookCluster setDefaultThreadFactory(@Nullable @Nullable java.util.concurrent.ThreadFactory factory)
WebhookClient instances.factory - The default thread factoryWebhookClientBuilder.setThreadFactory(java.util.concurrent.ThreadFactory)@NotNull public @NotNull WebhookCluster setAllowedMentions(@Nullable @Nullable AllowedMentions allowedMentions)
AllowedMentions for more details.allowedMentions - The default mention whitelist@NotNull public @NotNull WebhookCluster setDefaultDaemon(boolean isDaemon)
WebhookClient instances should be daemon by default.isDaemon - True, if clients should be daemonWebhookClientBuilder.setDaemon(boolean)@NotNull public @NotNull WebhookCluster buildWebhook(long id, @NotNull @NotNull java.lang.String token)
WebhookClient instance with the provided
components and specified default configurations.id - The id of the webhooktoken - The token of the webhookjava.lang.NullPointerException - If the token is null@NotNull public @NotNull WebhookClientBuilder newBuilder(long id, @NotNull @NotNull java.lang.String token)
WebhookClientBuilder instance with the provided
components and specified default configurations.
id - The id of the webhooktoken - The token of the webhookjava.lang.NullPointerException - If the token is null@NotNull public @NotNull WebhookCluster addWebhooks(@NotNull WebhookClient... clients)
clients - The clients to addjava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If at least one of the clients is already shutdown@NotNull public @NotNull WebhookCluster addWebhooks(@NotNull @NotNull java.util.Collection<WebhookClient> clients)
clients - The clients to addjava.lang.NullPointerException - If provided with nulljava.lang.IllegalArgumentException - If at least one of the clients is already shutdown@NotNull public @NotNull WebhookCluster removeWebhooks(@NotNull WebhookClient... clients)
clients - The clients to removejava.lang.NullPointerException - If provided with null@NotNull public @NotNull WebhookCluster removeWebhooks(@NotNull @NotNull java.util.Collection<WebhookClient> clients)
clients - The clients to removejava.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<WebhookClient> removeIf(@NotNull @NotNull java.util.function.Predicate<WebhookClient> predicate)
predicate - The filter to decide whether to remove a client or notList of the removed webhooksjava.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<WebhookClient> closeIf(@NotNull @NotNull java.util.function.Predicate<WebhookClient> predicate)
predicate - The filter to decide whether to close and remove the clientList of the removed webhooksjava.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<WebhookClient> getWebhooks()
@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> multicast(@NotNull @NotNull java.util.function.Predicate<WebhookClient> filter, @NotNull @NotNull WebhookMessage message)
This will override the default AllowedMentions of the client!
filter - The filter to decide whether a client should be targetedmessage - The message to sendjava.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull WebhookMessage message)
This will override the default AllowedMentions of the client!
message - The message to sendjava.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull WebhookEmbed first, @NotNull WebhookEmbed... embeds)
first - The first embed to sendembeds - Optional additional embeds to send, up to 10java.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull java.util.Collection<WebhookEmbed> embeds)
embeds - The embeds to send, up to 10java.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull java.lang.String content)
content - The message to sendjava.lang.NullPointerException - If provided with null@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull java.io.File file)
file - The file to sendjava.lang.NullPointerException - If provided with nulljava.io.UncheckedIOException - If an I/O error occurs@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull java.lang.String fileName, @NotNull @NotNull java.io.File file)
fileName - The alternative file name to usefile - The file to sendjava.lang.NullPointerException - If provided with nulljava.io.UncheckedIOException - If an I/O error occurs@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull java.lang.String fileName, @NotNull @NotNull java.io.InputStream data)
fileName - The alternative file name to usedata - The data to sendjava.lang.NullPointerException - If provided with nulljava.io.UncheckedIOException - If an I/O error occurs@NotNull public @NotNull java.util.List<java.util.concurrent.CompletableFuture<ReadonlyMessage>> broadcast(@NotNull @NotNull java.lang.String fileName, @NotNull @NotNull byte[] data)
fileName - The alternative file name to usedata - The data to sendjava.lang.NullPointerException - If provided with nullpublic void close()
close in interface java.lang.AutoCloseable