All Downloads are FREE. Search and download functionalities are using the official Maven repository.

discord4j.rest.request.RouterOptions Maven / Gradle / Ivy

There is a newer version: 3.3.0-RC2
Show newest version
/*
 * This file is part of Discord4J.
 *
 * Discord4J is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Discord4J is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Discord4J. If not, see .
 */

package discord4j.rest.request;

import discord4j.common.ReactorResources;
import discord4j.rest.http.ExchangeStrategies;
import discord4j.rest.http.client.AuthorizationScheme;
import discord4j.rest.response.ResponseFunction;

import java.util.List;
import java.util.Objects;

/**
 * Options used to control the behavior of a {@link Router}.
 */
public class RouterOptions {

    private final AuthorizationScheme authorizationScheme;
    private final String token;
    private final ReactorResources reactorResources;
    private final ExchangeStrategies exchangeStrategies;
    private final List responseTransformers;
    private final GlobalRateLimiter globalRateLimiter;
    private final RequestQueueFactory requestQueueFactory;
    private final String discordBaseUrl;

    public RouterOptions(String token, ReactorResources reactorResources, ExchangeStrategies exchangeStrategies,
                         List responseTransformers, GlobalRateLimiter globalRateLimiter,
                         RequestQueueFactory requestQueueFactory, String discordBaseUrl) {
        this(AuthorizationScheme.BOT, token, reactorResources, exchangeStrategies,
                responseTransformers, globalRateLimiter,
                requestQueueFactory, discordBaseUrl);
    }

    public RouterOptions(AuthorizationScheme authorizationScheme, String token, ReactorResources reactorResources,
                         ExchangeStrategies exchangeStrategies, List responseTransformers,
                         GlobalRateLimiter globalRateLimiter, RequestQueueFactory requestQueueFactory,
                         String discordBaseUrl) {
        this.authorizationScheme = Objects.requireNonNull(authorizationScheme, "authorizationScheme");
        this.token = Objects.requireNonNull(token, "token");
        this.reactorResources = Objects.requireNonNull(reactorResources, "reactorResources");
        this.exchangeStrategies = Objects.requireNonNull(exchangeStrategies, "exchangeStrategies");
        this.responseTransformers = Objects.requireNonNull(responseTransformers, "responseTransformers");
        this.globalRateLimiter = Objects.requireNonNull(globalRateLimiter, "globalRateLimiter");
        this.requestQueueFactory = Objects.requireNonNull(requestQueueFactory, "requestQueueFactory");
        this.discordBaseUrl = Objects.requireNonNull(discordBaseUrl, "discordBaseUrl");
    }

    public AuthorizationScheme getAuthorizationScheme() {
        return authorizationScheme;
    }

    /**
     * Returns the currently configured token.
     *
     * @return the configured token
     */
    public String getToken() {
        return token;
    }

    /**
     * Returns the currently configured {@link ReactorResources}.
     *
     * @return the configured {@link ReactorResources}
     */
    public ReactorResources getReactorResources() {
        return reactorResources;
    }

    /**
     * Returns the currently configured {@link ExchangeStrategies}.
     *
     * @return the configured {@link ExchangeStrategies}
     */
    public ExchangeStrategies getExchangeStrategies() {
        return exchangeStrategies;
    }

    /**
     * Returns the list of {@link ResponseFunction} transformations that can be applied to every response. They are
     * to be processed in the given order.
     *
     * @return a list of {@link ResponseFunction} objects.
     */
    public List getResponseTransformers() {
        return responseTransformers;
    }

    /**
     * Returns the currently configured {@link GlobalRateLimiter}.
     *
     * @return the configured {@link GlobalRateLimiter}
     */
    public GlobalRateLimiter getGlobalRateLimiter() {
        return globalRateLimiter;
    }

    /**
     * Returns the {@link RequestQueueFactory} to use for creating {@link RequestQueue} instances.
     *
     * @return the configured {@link RequestQueueFactory}
     */
    public RequestQueueFactory getRequestQueueFactory() {
        return requestQueueFactory;
    }

    /**
     * Returns the base url of the Discord API.
     *
     * @return the configured discord api base url
     */
    public String getDiscordBaseUrl() {
        return discordBaseUrl;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy