Package com.flagsmith

Class FlagsmithClient.Builder

    • Method Detail

      • setApiKey

        public FlagsmithClient.Builder setApiKey​(String apiKey)
        Set the environment API key.
        Parameters:
        apiKey - the api key for environment
        Returns:
        the Builder
      • setDefaultFlagValueFunction

        public FlagsmithClient.Builder setDefaultFlagValueFunction​(@NonNull
                                                                   @NonNull Function<String,​BaseFlag> defaultFlagValueFunction)
        When a flag does not exist in Flagsmith or there is an error, the SDK will return null by default.

        If you would like to override this default behaviour, you can use this method. By default it will return null for any flags that it does not recognise.

        Parameters:
        defaultFlagValueFunction - the new function to use as default flag values
        Returns:
        the Builder
      • enableLogging

        public FlagsmithClient.Builder enableLogging​(FlagsmithLoggerLevel level)
        Enables logging, the project importing this module must include an implementation slf4j in their pom.
        Parameters:
        level - log error level.
        Returns:
        the Builder
      • enableLogging

        public FlagsmithClient.Builder enableLogging()
        Enables logging, the project importing this module must include an implementation slf4j in their pom.
        Returns:
        the Builder
      • withConfiguration

        public FlagsmithClient.Builder withConfiguration​(FlagsmithConfig config)
        Override default FlagsmithConfig for Flagsmith API.
        Parameters:
        config - an FlagsmithConfig to override default one.
        Returns:
        the Builder
      • withApiUrl

        public FlagsmithClient.Builder withApiUrl​(String apiUrl)
        Set the base URL for Flagsmith API, overriding default one.
        Parameters:
        apiUrl - the new base URI for the API.
        Returns:
        the Builder
      • withCustomHttpHeaders

        public FlagsmithClient.Builder withCustomHttpHeaders​(HashMap<String,​String> customHeaders)
        Add custom HTTP headers to the calls.
        Parameters:
        customHeaders - headers.
        Returns:
        the Builder
      • withCache

        public FlagsmithClient.Builder withCache​(FlagsmithCacheConfig cacheConfig)
        Enable in-memory caching for the Flagsmith API.

        If no other cache configuration is set, the Caffeine defaults will be used, i.e. no limit

        Parameters:
        cacheConfig - an FlagsmithCacheConfig.
        Returns:
        the Builder
      • withFlagsmithApiWrapper

        public FlagsmithClient.Builder withFlagsmithApiWrapper​(FlagsmithApiWrapper flagsmithApiWrapper)
        Set the api wrapper.
        Parameters:
        flagsmithApiWrapper - FlagsmithAPIWrapper object
        Returns:
        the Builder
      • build

        public FlagsmithClient build()
        Builds a FlagsmithClient.
        Returns:
        a FlagsmithClient