Package 

Class ConfigCatClient

  • All Implemented Interfaces:
    com.configcat.ConfigurationProvider , java.io.Closeable , java.lang.AutoCloseable

    
    public final class ConfigCatClient
     implements ConfigurationProvider
                        

    A client for handling configurations provided by ConfigCat.

    • Method Detail

      • setDefaultUser

         void setDefaultUser(User user)

        Sets the default user.

        Parameters:
        user - the default user.
      • getValue

         <T> T getValue(Class<T> classOfT, String key, T defaultValue)

        Gets the value of a feature flag or setting as T identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        defaultValue - in case of any failure, this value will be returned.
      • getValue

         <T> T getValue(Class<T> classOfT, String key, User user, T defaultValue)

        Gets the value of a feature flag or setting as T identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        user - the user object.
        defaultValue - in case of any failure, this value will be returned.
      • getValueAsync

         <T> CompletableFuture<T> getValueAsync(Class<T> classOfT, String key, T defaultValue)

        Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        defaultValue - in case of any failure, this value will be returned.
      • getValueAsync

         <T> CompletableFuture<T> getValueAsync(Class<T> classOfT, String key, User user, T defaultValue)

        Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        user - the user object.
        defaultValue - in case of any failure, this value will be returned.
      • getValueDetails

         <T> EvaluationDetails<T> getValueDetails(Class<T> classOfT, String key, T defaultValue)

        Gets the value of a feature flag or setting as T identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        defaultValue - in case of any failure, this value will be returned.
      • getValueDetails

         <T> EvaluationDetails<T> getValueDetails(Class<T> classOfT, String key, User user, T defaultValue)

        Gets the value of a feature flag or setting as T identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        user - the user object.
        defaultValue - in case of any failure, this value will be returned.
      • getValueDetailsAsync

         <T> CompletableFuture<EvaluationDetails<T>> getValueDetailsAsync(Class<T> classOfT, String key, T defaultValue)

        Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        defaultValue - in case of any failure, this value will be returned.
      • getValueDetailsAsync

         <T> CompletableFuture<EvaluationDetails<T>> getValueDetailsAsync(Class<T> classOfT, String key, User user, T defaultValue)

        Gets the value of a feature flag or setting as T asynchronously identified by the given {@code key}.

        Parameters:
        classOfT - the class of T.
        key - the identifier of a feature flag or setting.
        user - the user object.
        defaultValue - in case of any failure, this value will be returned.
      • getAllValues

         Map<String, Object> getAllValues(User user)

        Gets the values of all feature flags or settings synchronously.

        Parameters:
        user - the user object.
      • getAllValuesAsync

         CompletableFuture<Map<String, Object>> getAllValuesAsync(User user)

        Gets the values of all feature flags or settings asynchronously.

        Parameters:
        user - the user object.
      • getKeyAndValue

         <T> Map.Entry<String, T> getKeyAndValue(Class<T> classOfT, String variationId)

        Gets the key of a setting and its value identified by the given Variation ID (analytics).

        Parameters:
        classOfT - the class of T.
        variationId - the Variation ID.
      • getKeyAndValueAsync

         <T> CompletableFuture<Map.Entry<String, T>> getKeyAndValueAsync(Class<T> classOfT, String variationId)

        Gets the key of a setting and its value identified by the given Variation ID (analytics).

        Parameters:
        classOfT - the class of T.
        variationId - the Variation ID.
      • setOnline

         void setOnline()

        Configures the SDK to allow HTTP requests.

      • setOffline

         void setOffline()

        Configures the SDK to not initiate HTTP requests and work only from its cache.

      • isOffline

         boolean isOffline()

        Indicates whether the SDK is in offline mode or not.

      • get

         static ConfigCatClient get(String sdkKey)

        Creates a new or gets an already existing ConfigCatClient for the given sdkKey.

        Parameters:
        sdkKey - the SDK Key for to communicate with the ConfigCat services.
      • get

         static ConfigCatClient get(String sdkKey, Consumer<ConfigCatClient.Options> optionsCallback)

        Creates a new or gets an already existing ConfigCatClient for the given sdkKey.

        Parameters:
        sdkKey - the SDK Key for to communicate with the ConfigCat services.
        optionsCallback - the options callback to set up the created ConfigCatClient instance.
      • closeAll

         static void closeAll()

        Closes all ConfigCatClient instances.