public final class ConfigCatClient extends java.lang.Object implements ConfigurationProvider
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigCatClient.Options
Options for configuring
ConfigCatClient instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearDefaultUser()
Set default user value to null.
|
void |
close() |
static void |
closeAll()
Close all ConfigCatClient instances.
|
RefreshResult |
forceRefresh()
Initiates a force refresh synchronously on the cached configuration.
|
java.util.concurrent.CompletableFuture<RefreshResult> |
forceRefreshAsync()
Initiates a force refresh asynchronously on the cached configuration.
|
static ConfigCatClient |
get(java.lang.String sdkKey)
Get a singleton ConfigCat Client for the sdk key, create a new client if not existed yet.
|
static ConfigCatClient |
get(java.lang.String sdkKey,
java.util.function.Consumer<ConfigCatClient.Options> optionsCallback)
Creates a new or gets an already existing ConfigCatClient for the given sdkKey.
|
java.util.Collection<java.lang.String> |
getAllKeys()
Gets a collection of all setting keys.
|
java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> |
getAllKeysAsync()
Gets a collection of all setting keys asynchronously.
|
java.util.List<EvaluationDetails<java.lang.Object>> |
getAllValueDetails(User user)
Gets the detailed values of all feature flags or settings synchronously.
|
java.util.concurrent.CompletableFuture<java.util.List<EvaluationDetails<java.lang.Object>>> |
getAllValueDetailsAsync(User user)
Gets the detailed values of all feature flags or settings asynchronously.
|
java.util.Map<java.lang.String,java.lang.Object> |
getAllValues(User user)
Gets the values of all feature flags or settings synchronously.
|
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> |
getAllValuesAsync(User user)
Gets the values of all feature flags or settings asynchronously.
|
ConfigCatHooks |
getHooks()
Access to hooks for event subscription.
|
<T> java.util.Map.Entry<java.lang.String,T> |
getKeyAndValue(java.lang.Class<T> classOfT,
java.lang.String variationId)
Gets the key of a setting and its value identified by the given Variation ID (analytics).
|
<T> java.util.concurrent.CompletableFuture<java.util.Map.Entry<java.lang.String,T>> |
getKeyAndValueAsync(java.lang.Class<T> classOfT,
java.lang.String variationId)
Gets the key of a setting and its value identified by the given Variation ID (analytics).
|
<T> T |
getValue(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
key. |
<T> T |
getValue(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
key. |
<T> java.util.concurrent.CompletableFuture<T> |
getValueAsync(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
key. |
<T> java.util.concurrent.CompletableFuture<T> |
getValueAsync(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
key. |
<T> EvaluationDetails<T> |
getValueDetails(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
key. |
<T> EvaluationDetails<T> |
getValueDetails(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
Gets the value of a feature flag or setting as T identified by the given
key. |
<T> java.util.concurrent.CompletableFuture<EvaluationDetails<T>> |
getValueDetailsAsync(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
key. |
<T> java.util.concurrent.CompletableFuture<EvaluationDetails<T>> |
getValueDetailsAsync(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
Gets the value of a feature flag or setting as T asynchronously identified by the given
key. |
boolean |
isClosed()
Get the client closed status.
|
boolean |
isOffline()
Get the client offline mode status.
|
void |
setDefaultUser(User defaultUser)
Sets defaultUser value.
|
void |
setOffline()
Set the client to offline mode.
|
void |
setOnline()
Set the client to online mode.
|
public <T> T getValue(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
ConfigurationProviderkey.getValue in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.defaultValue - in case of any failure, this value will be returned.public <T> T getValue(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
ConfigurationProviderkey.getValue in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.user - the user object.defaultValue - in case of any failure, this value will be returned.public <T> java.util.concurrent.CompletableFuture<T> getValueAsync(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
ConfigurationProviderkey.getValueAsync in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.defaultValue - in case of any failure, this value will be returned.public <T> java.util.concurrent.CompletableFuture<T> getValueAsync(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
ConfigurationProviderkey.getValueAsync in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.user - the user object.defaultValue - in case of any failure, this value will be returned.public <T> EvaluationDetails<T> getValueDetails(java.lang.Class<T> classOfT, java.lang.String key, T defaultValue)
ConfigurationProviderkey.getValueDetails in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.defaultValue - in case of any failure, this value will be returned.public <T> EvaluationDetails<T> getValueDetails(java.lang.Class<T> classOfT, java.lang.String key, User user, T defaultValue)
ConfigurationProviderkey.getValueDetails in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.user - the user object.defaultValue - in case of any failure, this value will be returned.public <T> java.util.concurrent.CompletableFuture<EvaluationDetails<T>> getValueDetailsAsync(java.lang.Class<T> classOfT, java.lang.String key, T defaultValue)
ConfigurationProviderkey.getValueDetailsAsync in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.defaultValue - in case of any failure, this value will be returned.public <T> java.util.concurrent.CompletableFuture<EvaluationDetails<T>> getValueDetailsAsync(java.lang.Class<T> classOfT, java.lang.String key, User user, T defaultValue)
ConfigurationProviderkey.getValueDetailsAsync in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the feature flag or setting.user - the user object.defaultValue - in case of any failure, this value will be returned.public java.util.Map<java.lang.String,java.lang.Object> getAllValues(User user)
ConfigurationProvidergetAllValues in interface ConfigurationProvideruser - the user object.public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> getAllValuesAsync(User user)
ConfigurationProvidergetAllValuesAsync in interface ConfigurationProvideruser - the user object.public java.util.List<EvaluationDetails<java.lang.Object>> getAllValueDetails(User user)
ConfigurationProvidergetAllValueDetails in interface ConfigurationProvideruser - the user object.public java.util.concurrent.CompletableFuture<java.util.List<EvaluationDetails<java.lang.Object>>> getAllValueDetailsAsync(User user)
ConfigurationProvidergetAllValueDetailsAsync in interface ConfigurationProvideruser - the user object.public <T> java.util.Map.Entry<java.lang.String,T> getKeyAndValue(java.lang.Class<T> classOfT,
java.lang.String variationId)
ConfigurationProvidergetKeyAndValue in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.variationId - the Variation ID.public <T> java.util.concurrent.CompletableFuture<java.util.Map.Entry<java.lang.String,T>> getKeyAndValueAsync(java.lang.Class<T> classOfT,
java.lang.String variationId)
ConfigurationProvidergetKeyAndValueAsync in interface ConfigurationProviderT - the type of the desired feature flag or setting.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.variationId - the Variation ID.public java.util.Collection<java.lang.String> getAllKeys()
ConfigurationProvidergetAllKeys in interface ConfigurationProviderpublic java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllKeysAsync()
ConfigurationProvidergetAllKeysAsync in interface ConfigurationProviderpublic RefreshResult forceRefresh()
ConfigurationProviderforceRefresh in interface ConfigurationProviderpublic java.util.concurrent.CompletableFuture<RefreshResult> forceRefreshAsync()
ConfigurationProviderforceRefreshAsync in interface ConfigurationProviderpublic void setDefaultUser(User defaultUser)
ConfigurationProvidersetDefaultUser in interface ConfigurationProviderdefaultUser - The new default user.public void clearDefaultUser()
ConfigurationProviderclearDefaultUser in interface ConfigurationProviderpublic boolean isClosed()
ConfigurationProviderisClosed in interface ConfigurationProviderpublic void setOnline()
ConfigurationProvidersetOnline in interface ConfigurationProviderpublic void setOffline()
ConfigurationProvidersetOffline in interface ConfigurationProviderpublic boolean isOffline()
ConfigurationProviderisOffline in interface ConfigurationProviderpublic ConfigCatHooks getHooks()
ConfigurationProvidergetHooks in interface ConfigurationProviderpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic static void closeAll()
throws java.io.IOException
java.io.IOException - If client resource close fails.public static ConfigCatClient get(java.lang.String sdkKey)
sdkKey - the client sdk key.public static ConfigCatClient get(java.lang.String sdkKey, java.util.function.Consumer<ConfigCatClient.Options> optionsCallback)
sdkKey - the SDK Key for to communicate with the ConfigCat services.optionsCallback - the options callback to set up the created ConfigCatClient instance.