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.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.
|
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 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 . |
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)
ConfigurationProvider
key
.getValue
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValue
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueAsync
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
key
.getValueAsync
in interface ConfigurationProvider
T
- 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)
ConfigurationProvider
getVariationId
in interface ConfigurationProvider
key
- 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)
ConfigurationProvider
getVariationId
in interface ConfigurationProvider
key
- 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)
ConfigurationProvider
getVariationIdAsync
in interface ConfigurationProvider
key
- 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)
ConfigurationProvider
getVariationIdAsync
in interface ConfigurationProvider
key
- 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()
ConfigurationProvider
getAllVariationIds
in interface ConfigurationProvider
public java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllVariationIdsAsync()
ConfigurationProvider
getAllVariationIdsAsync
in interface ConfigurationProvider
public java.util.Collection<java.lang.String> getAllVariationIds(User user)
ConfigurationProvider
getAllVariationIds
in interface ConfigurationProvider
user
- the user object to identify the caller.public java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllVariationIdsAsync(User user)
ConfigurationProvider
getAllVariationIdsAsync
in interface ConfigurationProvider
user
- the user object to identify the caller.public java.util.Map<java.lang.String,java.lang.Object> getAllValues(User user)
ConfigurationProvider
getAllValues
in interface ConfigurationProvider
user
- the user object to identify the caller.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 to identify the caller.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 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)
ConfigurationProvider
getKeyAndValueAsync
in interface ConfigurationProvider
T
- 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()
ConfigurationProvider
getAllKeys
in interface ConfigurationProvider
public java.util.concurrent.CompletableFuture<java.util.Collection<java.lang.String>> getAllKeysAsync()
ConfigurationProvider
getAllKeysAsync
in interface ConfigurationProvider
public void forceRefresh()
ConfigurationProvider
forceRefresh
in interface ConfigurationProvider
public java.util.concurrent.CompletableFuture<java.lang.Void> forceRefreshAsync()
ConfigurationProvider
forceRefreshAsync
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 ConfigCatClient.Builder newBuilder()