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)
ConfigurationProvider
key
.getValue
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValue
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueAsync
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueAsync
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueDetails
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueDetails
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueDetailsAsync
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueDetailsAsync
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
getAllValues
in interface ConfigurationProvider
user
- the user object.public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.Object>> getAllValuesAsync(User user)
ConfigurationProvider
getAllValuesAsync
in interface ConfigurationProvider
user
- the user object.public java.util.List<EvaluationDetails<java.lang.Object>> getAllValueDetails(User user)
ConfigurationProvider
getAllValueDetails
in interface ConfigurationProvider
user
- the user object.public java.util.concurrent.CompletableFuture<java.util.List<EvaluationDetails<java.lang.Object>>> getAllValueDetailsAsync(User user)
ConfigurationProvider
getAllValueDetailsAsync
in interface ConfigurationProvider
user
- the user object.public <T> java.util.Map.Entry<java.lang.String,T> getKeyAndValue(java.lang.Class<T> classOfT, java.lang.String variationId)
ConfigurationProvider
getKeyAndValue
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
getKeyAndValueAsync
in interface ConfigurationProvider
T
- 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()
ConfigurationProvider
getAllKeys
in interface ConfigurationProvider
public java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllKeysAsync()
ConfigurationProvider
getAllKeysAsync
in interface ConfigurationProvider
public RefreshResult forceRefresh()
ConfigurationProvider
forceRefresh
in interface ConfigurationProvider
public java.util.concurrent.CompletableFuture<RefreshResult> forceRefreshAsync()
ConfigurationProvider
forceRefreshAsync
in interface ConfigurationProvider
public void setDefaultUser(User defaultUser)
ConfigurationProvider
setDefaultUser
in interface ConfigurationProvider
defaultUser
- The new default user.public void clearDefaultUser()
ConfigurationProvider
clearDefaultUser
in interface ConfigurationProvider
public boolean isClosed()
ConfigurationProvider
isClosed
in interface ConfigurationProvider
public void setOnline()
ConfigurationProvider
setOnline
in interface ConfigurationProvider
public void setOffline()
ConfigurationProvider
setOffline
in interface ConfigurationProvider
public boolean isOffline()
ConfigurationProvider
isOffline
in interface ConfigurationProvider
public ConfigCatHooks getHooks()
ConfigurationProvider
getHooks
in interface ConfigurationProvider
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
java.io.IOException
public 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.