001package com.box.sdk;
002
003/**
004 * Global settings to apply to all API requests.
005 */
006public final class BoxGlobalSettings {
007    private static int connectTimeout = 0;
008    private static int readTimeout = 0;
009    private static int maxRetryAttempts = BoxAPIConnection.DEFAULT_MAX_RETRIES;
010    private static boolean useZstdCompression = true;
011
012    private BoxGlobalSettings() {
013    }
014
015    /**
016     * Returns the current global connect timeout.
017     *
018     * @return connect timeout
019     */
020    public static int getConnectTimeout() {
021        return connectTimeout;
022    }
023
024    /**
025     * Sets the global connect timeout.
026     *
027     * @param connectTimeout timeout in milliseconds
028     */
029    public static void setConnectTimeout(int connectTimeout) {
030        BoxGlobalSettings.connectTimeout = connectTimeout;
031    }
032
033    /**
034     * Returns the current global read timeout.
035     *
036     * @return read timeout
037     */
038    public static int getReadTimeout() {
039        return readTimeout;
040    }
041
042    /**
043     * Sets the global read timeout.
044     *
045     * @param readTimeout timeout in milliseconds
046     */
047    public static void setReadTimeout(int readTimeout) {
048        BoxGlobalSettings.readTimeout = readTimeout;
049    }
050
051
052    /**
053     * Returns the global maximum number of times an API request will be retried after an error response
054     * is received.
055     *
056     * @return max number of request attempts
057     */
058    public static int getMaxRetryAttempts() {
059        return maxRetryAttempts;
060    }
061
062    /**
063     * Sets the global maximum number of times an API request will be retried after an error response
064     * is received.
065     *
066     * @param attempts maximum number of request attempts
067     */
068    public static void setMaxRetryAttempts(int attempts) {
069        BoxGlobalSettings.maxRetryAttempts = attempts;
070    }
071
072    /*
073     * Returns the global settings for using Zstd compression.
074     * @return true if Zstd compression is enabled, false otherwise
075     */
076    public static boolean getUseZstdCompression() {
077        return useZstdCompression;
078    }
079
080    /*
081     * Sets the global settings for using Zstd compression.
082     * @param useZstdCompression true to enable Zstd compression, false otherwise
083     */
084    public static void setUseZstdCompression(boolean useZstdCompression) {
085        BoxGlobalSettings.useZstdCompression = useZstdCompression;
086    }
087}