public 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 apiKey)
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.
|
<T extends RefreshPolicy> |
getRefreshPolicy(java.lang.Class<T> classOfT)
Gets the internal refresh policy.
|
<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. |
static ConfigCatClient.Builder |
newBuilder()
Creates a new builder instance.
|
public ConfigCatClient(java.lang.String apiKey)
apiKey - the token which identifies your project configuration.public <T extends RefreshPolicy> T getRefreshPolicy(java.lang.Class<T> classOfT)
ConfigurationProvidergetRefreshPolicy in interface ConfigurationProviderT - the type of the desired policy.classOfT - the class of T.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.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()