Package com.flagsmith
Class FlagsmithClient.Builder
java.lang.Object
com.flagsmith.FlagsmithClient.Builder
- Enclosing class:
- FlagsmithClient
public static class FlagsmithClient.Builder extends Object
-
Method Summary
Modifier and Type Method Description FlagsmithClientbuild()Builds a FlagsmithClient.FlagsmithClient.BuilderenableLogging()Enables logging, the project importing this module must include an implementation slf4j in their pom.FlagsmithClient.BuilderenableLogging(FlagsmithLoggerLevel level)Enables logging, the project importing this module must include an implementation slf4j in their pom.FlagsmithClient.BuilderenableLogging(org.slf4j.Logger logger)Enables logging, the project importing this module must include an implementation slf4j in their pom.FlagsmithClient.BuildersetApiKey(String apiKey)Set the environment API key.FlagsmithClient.BuildersetDefaultFlagValueFunction(@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.FlagsmithClient.BuilderwithApiUrl(String apiUrl)Set the base URL for Flagsmith API, overriding default one.FlagsmithClient.BuilderwithCache(FlagsmithCacheConfig cacheConfig)Enable in-memory caching for the Flagsmith API.FlagsmithClient.BuilderwithConfiguration(FlagsmithConfig config)Override default FlagsmithConfig for Flagsmith API.FlagsmithClient.BuilderwithCustomHttpHeaders(HashMap<String,String> customHeaders)Add custom HTTP headers to the calls.FlagsmithClient.BuilderwithFlagsmithApiWrapper(FlagsmithApiWrapper flagsmithApiWrapper)Set the api wrapper.FlagsmithClient.BuilderwithPollingManager(PollingManager manager)Set the polling manager.
-
Method Details
-
setApiKey
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
Enables logging, the project importing this module must include an implementation slf4j in their pom.- Parameters:
level- log error level.- Returns:
- the Builder
-
enableLogging
Enables logging, the project importing this module must include an implementation slf4j in their pom.- Returns:
- the Builder
-
enableLogging
Enables logging, the project importing this module must include an implementation slf4j in their pom.- Returns:
- the Builder
-
withConfiguration
Override default FlagsmithConfig for Flagsmith API.- Parameters:
config- an FlagsmithConfig to override default one.- Returns:
- the Builder
-
withApiUrl
Set the base URL for Flagsmith API, overriding default one.- Parameters:
apiUrl- the new base URI for the API.- Returns:
- the Builder
-
withCustomHttpHeaders
Add custom HTTP headers to the calls.- Parameters:
customHeaders- headers.- Returns:
- the Builder
-
withCache
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
-
withPollingManager
Set the polling manager.- Parameters:
manager- polling manager object
-
withFlagsmithApiWrapper
Set the api wrapper.- Parameters:
flagsmithApiWrapper- FlagsmithAPIWrapper object- Returns:
- the Builder
-
build
Builds a FlagsmithClient.- Returns:
- a FlagsmithClient
-