public final class ConfigCatClient extends java.lang.Object implements ConfigurationProvider
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigCatClient.Builder
A builder that helps construct a
ConfigCatClient instance. |
| Constructor and Description |
|---|
ConfigCatClient(java.lang.String sdkKey)
Constructs a new client instance with the default configuration.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
forceRefresh()
Initiates a force refresh synchronously on the cached configuration.
|
java.util.concurrent.CompletableFuture<java.lang.Void> |
forceRefreshAsync()
Initiates a force refresh asynchronously on the cached configuration.
|
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.Collection<java.lang.String> |
getAllVariationIds()
Gets the Variation IDs (analytics) of all feature flags or settings synchronously.
|
java.util.Collection<java.lang.String> |
getAllVariationIds(User user)
Gets the Variation IDs (analytics) of all feature flags or settings synchronously.
|
java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> |
getAllVariationIdsAsync()
Gets the Variation IDs (analytics) of all feature flags or settings asynchronously.
|
java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> |
getAllVariationIdsAsync(User user)
Gets the Variation IDs (analytics) of all feature flags or settings asynchronously.
|
<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 a value synchronously as T from the configuration identified by the given
key. |
<T> T |
getValue(java.lang.Class<T> classOfT,
java.lang.String key,
User user,
T defaultValue)
Gets a value synchronously as T from the configuration identified by the given
key. |
<T> java.util.concurrent.CompletableFuture<T> |
getValueAsync(java.lang.Class<T> classOfT,
java.lang.String key,
T defaultValue)
Gets a value asynchronously as T from the configuration 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 a value asynchronously as T from the configuration identified by the given
key. |
java.lang.String |
getVariationId(java.lang.String key,
java.lang.String defaultVariationId)
Gets the Variation ID (analytics) of a feature flag or setting synchronously based on its key.
|
java.lang.String |
getVariationId(java.lang.String key,
User user,
java.lang.String defaultVariationId)
Gets the Variation ID (analytics) of a feature flag or setting synchronously based on its key.
|
java.util.concurrent.CompletableFuture<java.lang.String> |
getVariationIdAsync(java.lang.String key,
java.lang.String defaultVariationId)
Gets the Variation ID (analytics) of a feature flag or setting asynchronously based on its key.
|
java.util.concurrent.CompletableFuture<java.lang.String> |
getVariationIdAsync(java.lang.String key,
User user,
java.lang.String defaultVariationId)
Gets the Variation ID (analytics) of a feature flag or setting asynchronously based on its key.
|
static ConfigCatClient.Builder |
newBuilder()
Creates a new builder instance.
|
public ConfigCatClient(java.lang.String sdkKey)
sdkKey - the token which identifies your project configuration.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 config value.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the configuration value.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 config value.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the configuration value.user - the user object to identify the caller.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 config value.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the configuration value.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 config value.classOfT - the class of T. Only String, Integer, Double or Boolean types are supported.key - the identifier of the configuration value.user - the user object to identify the caller.defaultValue - in case of any failure, this value will be returned.public java.lang.String getVariationId(java.lang.String key,
java.lang.String defaultVariationId)
ConfigurationProvidergetVariationId in interface ConfigurationProviderkey - the identifier of the configuration value.defaultVariationId - in case of any failure, this value will be returned.public java.lang.String getVariationId(java.lang.String key,
User user,
java.lang.String defaultVariationId)
ConfigurationProvidergetVariationId in interface ConfigurationProviderkey - the identifier of the configuration value.user - the user object to identify the caller.defaultVariationId - in case of any failure, this value will be returned.public java.util.concurrent.CompletableFuture<java.lang.String> getVariationIdAsync(java.lang.String key,
java.lang.String defaultVariationId)
ConfigurationProvidergetVariationIdAsync in interface ConfigurationProviderkey - the identifier of the configuration value.defaultVariationId - in case of any failure, this value will be returned.public java.util.concurrent.CompletableFuture<java.lang.String> getVariationIdAsync(java.lang.String key,
User user,
java.lang.String defaultVariationId)
ConfigurationProvidergetVariationIdAsync in interface ConfigurationProviderkey - the identifier of the configuration value.user - the user object to identify the caller.defaultVariationId - in case of any failure, this value will be returned.public java.util.Collection<java.lang.String> getAllVariationIds()
ConfigurationProvidergetAllVariationIds in interface ConfigurationProviderpublic java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllVariationIdsAsync()
ConfigurationProvidergetAllVariationIdsAsync in interface ConfigurationProviderpublic java.util.Collection<java.lang.String> getAllVariationIds(User user)
ConfigurationProvidergetAllVariationIds in interface ConfigurationProvideruser - the user object to identify the caller.public java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllVariationIdsAsync(User user)
ConfigurationProvidergetAllVariationIdsAsync in interface ConfigurationProvideruser - the user object to identify the caller.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 config value.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 config value.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 void forceRefresh()
ConfigurationProviderforceRefresh in interface ConfigurationProviderpublic java.util.concurrent.CompletableFuture<java.lang.Void> forceRefreshAsync()
ConfigurationProviderforceRefreshAsync in interface ConfigurationProviderpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablejava.io.IOExceptionpublic static ConfigCatClient.Builder newBuilder()