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
All Methods Instance Methods Concrete Methods 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.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 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
-
withPollingManager
public FlagsmithClient.Builder withPollingManager(PollingManager manager)
Set the polling manager.- Parameters:
manager- polling manager object- Returns:
-
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
-
-