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