-
- All Implemented Interfaces:
-
com.configcat.ConfigurationProvider,java.io.Closeable,java.lang.AutoCloseable
public final class ConfigCatClient implements ConfigurationProvider
A client for handling configurations provided by ConfigCat.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classConfigCatClient.OptionsConfiguration options for a ConfigCatClient instance.
-
Field Summary
Fields Modifier and Type Field Description private final ConfigCatHookshooksprivate UserdefaultUser
-
Method Summary
Modifier and Type Method Description ConfigCatHooksgetHooks()Access to hooks for event subscription. voidsetDefaultUser(User user)Sets the default user. <T> TgetValue(Class<T> classOfT, String key, T defaultValue)Gets the value of a feature flag or setting as T identified by the given {@code key}.<T> TgetValue(Class<T> classOfT, String key, User user, T defaultValue)Gets the value of a feature flag or setting as T identified by the given {@code key}.<T> CompletableFuture<T>getValueAsync(Class<T> classOfT, String key, T defaultValue)Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.<T> CompletableFuture<T>getValueAsync(Class<T> classOfT, String key, User user, T defaultValue)Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.<T> EvaluationDetails<T>getValueDetails(Class<T> classOfT, String key, T defaultValue)Gets the value of a feature flag or setting as T identified by the given {@code key}.<T> EvaluationDetails<T>getValueDetails(Class<T> classOfT, String key, User user, T defaultValue)Gets the value of a feature flag or setting as T identified by the given {@code key}.<T> CompletableFuture<EvaluationDetails<T>>getValueDetailsAsync(Class<T> classOfT, String key, T defaultValue)Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.<T> CompletableFuture<EvaluationDetails<T>>getValueDetailsAsync(Class<T> classOfT, String key, User user, T defaultValue)Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.Map<String, Object>getAllValues()Gets the values of all feature flags or settings synchronously. Map<String, Object>getAllValues(User user)Gets the values of all feature flags or settings synchronously. CompletableFuture<Map<String, Object>>getAllValuesAsync()Gets the values of all feature flags or settings asynchronously. CompletableFuture<Map<String, Object>>getAllValuesAsync(User user)Gets the values of all feature flags or settings asynchronously. List<EvaluationDetails<out Object>>getAllValueDetails()Gets the detailed values of all feature flags or settings synchronously. List<EvaluationDetails<out Object>>getAllValueDetails(User user)Gets the detailed values of all feature flags or settings synchronously. CompletableFuture<List<EvaluationDetails<out Object>>>getAllValueDetailsAsync()Gets the detailed values of all feature flags or settings asynchronously. CompletableFuture<List<EvaluationDetails<out Object>>>getAllValueDetailsAsync(User user)Gets the detailed values of all feature flags or settings asynchronously. <T> Map.Entry<String, T>getKeyAndValue(Class<T> classOfT, String variationId)Gets the key of a setting and its value identified by the given Variation ID (analytics). <T> CompletableFuture<Map.Entry<String, T>>getKeyAndValueAsync(Class<T> classOfT, String variationId)Gets the key of a setting and its value identified by the given Variation ID (analytics). Collection<String>getAllKeys()Gets a collection of all setting keys. CompletableFuture<Collection<String>>getAllKeysAsync()Gets a collection of all setting keys asynchronously. RefreshResultforceRefresh()Initiates a force refresh synchronously on the cached configuration. CompletableFuture<RefreshResult>forceRefreshAsync()Initiates a force refresh asynchronously on the cached configuration. voidclearDefaultUser()Sets the default user to null. voidsetOnline()Configures the SDK to allow HTTP requests. voidsetOffline()Configures the SDK to not initiate HTTP requests and work only from its cache. booleanisOffline()Indicates whether the SDK is in offline mode or not. voidclose()static ConfigCatClientget(String sdkKey)Creates a new or gets an already existing ConfigCatClient for the given sdkKey. static ConfigCatClientget(String sdkKey, Consumer<ConfigCatClient.Options> optionsCallback)Creates a new or gets an already existing ConfigCatClient for the given sdkKey. static voidcloseAll()Closes all ConfigCatClient instances. -
-
Method Detail
-
getHooks
ConfigCatHooks getHooks()
Access to hooks for event subscription.
-
setDefaultUser
void setDefaultUser(User user)
Sets the default user.
- Parameters:
user- the default user.
-
getValue
<T> T getValue(Class<T> classOfT, String key, T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.defaultValue- in case of any failure, this value will be returned.
-
getValue
<T> T getValue(Class<T> classOfT, String key, User user, T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.user- the user object.defaultValue- in case of any failure, this value will be returned.
-
getValueAsync
<T> CompletableFuture<T> getValueAsync(Class<T> classOfT, String key, T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.defaultValue- in case of any failure, this value will be returned.
-
getValueAsync
<T> CompletableFuture<T> getValueAsync(Class<T> classOfT, String key, User user, T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.user- the user object.defaultValue- in case of any failure, this value will be returned.
-
getValueDetails
<T> EvaluationDetails<T> getValueDetails(Class<T> classOfT, String key, T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.defaultValue- in case of any failure, this value will be returned.
-
getValueDetails
<T> EvaluationDetails<T> getValueDetails(Class<T> classOfT, String key, User user, T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.user- the user object.defaultValue- in case of any failure, this value will be returned.
-
getValueDetailsAsync
<T> CompletableFuture<EvaluationDetails<T>> getValueDetailsAsync(Class<T> classOfT, String key, T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.defaultValue- in case of any failure, this value will be returned.
-
getValueDetailsAsync
<T> CompletableFuture<EvaluationDetails<T>> getValueDetailsAsync(Class<T> classOfT, String key, User user, T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
{@code key}.- Parameters:
classOfT- the class of T.key- the identifier of a feature flag or setting.user- the user object.defaultValue- in case of any failure, this value will be returned.
-
getAllValues
Map<String, Object> getAllValues()
Gets the values of all feature flags or settings synchronously.
-
getAllValues
Map<String, Object> getAllValues(User user)
Gets the values of all feature flags or settings synchronously.
- Parameters:
user- the user object.
-
getAllValuesAsync
CompletableFuture<Map<String, Object>> getAllValuesAsync()
Gets the values of all feature flags or settings asynchronously.
-
getAllValuesAsync
CompletableFuture<Map<String, Object>> getAllValuesAsync(User user)
Gets the values of all feature flags or settings asynchronously.
- Parameters:
user- the user object.
-
getAllValueDetails
List<EvaluationDetails<out Object>> getAllValueDetails()
Gets the detailed values of all feature flags or settings synchronously.
-
getAllValueDetails
List<EvaluationDetails<out Object>> getAllValueDetails(User user)
Gets the detailed values of all feature flags or settings synchronously.
- Parameters:
user- the user object.
-
getAllValueDetailsAsync
CompletableFuture<List<EvaluationDetails<out Object>>> getAllValueDetailsAsync()
Gets the detailed values of all feature flags or settings asynchronously.
-
getAllValueDetailsAsync
CompletableFuture<List<EvaluationDetails<out Object>>> getAllValueDetailsAsync(User user)
Gets the detailed values of all feature flags or settings asynchronously.
- Parameters:
user- the user object.
-
getKeyAndValue
<T> Map.Entry<String, T> getKeyAndValue(Class<T> classOfT, String variationId)
Gets the key of a setting and its value identified by the given Variation ID (analytics).
- Parameters:
classOfT- the class of T.variationId- the Variation ID.
-
getKeyAndValueAsync
<T> CompletableFuture<Map.Entry<String, T>> getKeyAndValueAsync(Class<T> classOfT, String variationId)
Gets the key of a setting and its value identified by the given Variation ID (analytics).
- Parameters:
classOfT- the class of T.variationId- the Variation ID.
-
getAllKeys
Collection<String> getAllKeys()
Gets a collection of all setting keys.
-
getAllKeysAsync
CompletableFuture<Collection<String>> getAllKeysAsync()
Gets a collection of all setting keys asynchronously.
-
forceRefresh
RefreshResult forceRefresh()
Initiates a force refresh synchronously on the cached configuration.
-
forceRefreshAsync
CompletableFuture<RefreshResult> forceRefreshAsync()
Initiates a force refresh asynchronously on the cached configuration.
-
clearDefaultUser
void clearDefaultUser()
Sets the default user to null.
-
setOnline
void setOnline()
Configures the SDK to allow HTTP requests.
-
setOffline
void setOffline()
Configures the SDK to not initiate HTTP requests and work only from its cache.
-
isOffline
boolean isOffline()
Indicates whether the SDK is in offline mode or not.
-
close
void close()
-
get
static ConfigCatClient get(String sdkKey)
Creates a new or gets an already existing ConfigCatClient for the given sdkKey.
- Parameters:
sdkKey- the SDK Key for to communicate with the ConfigCat services.
-
get
static ConfigCatClient get(String sdkKey, Consumer<ConfigCatClient.Options> optionsCallback)
Creates a new or gets an already existing ConfigCatClient for the given sdkKey.
- Parameters:
sdkKey- the SDK Key for to communicate with the ConfigCat services.optionsCallback- the options callback to set up the created ConfigCatClient instance.
-
closeAll
static void closeAll()
Closes all ConfigCatClient instances.
-
-
-
-