public static class FlagsmithClient.Builder extends Object
| Modifier and Type | Method and Description |
|---|---|
FlagsmithClient |
build()
Builds a FlagsmithClient.
|
FlagsmithClient.Builder |
enableLogging()
Enables logging, the project importing this module must include an implementation slf4j in
their pom.
|
FlagsmithClient.Builder |
enableLogging(FlagsmithLoggerLevel level)
Enables logging, the project importing this module must include an implementation slf4j in
their pom.
|
FlagsmithClient.Builder |
setApiKey(String apiKey)
Set the environment API key.
|
FlagsmithClient.Builder |
setDefaultFeatureFlags(@NonNull Set<String> defaultFeatureFlags)
When a flag does not exist in Flagsmith or there is an error, the SDK will return an empty
list of flags by default.
|
FlagsmithClient.Builder |
setDefaultFlagPredicate(@NonNull Predicate<String> defaultFlagPredicate)
When a flag does not exist in Flagsmith or there is an error, the SDK will return false by
default.
|
FlagsmithClient.Builder |
setDefaultFlagValueFunction(@NonNull Function<String,String> defaultFlagValueFunction)
When a flag does not exist in Flagsmith or there is an error, the SDK will return null by
default.
|
FlagsmithClient.Builder |
withApiUrl(String apiUrl)
Set the base URL for Flagsmith API, overriding default one.
|
FlagsmithClient.Builder |
withCache(FlagsmithCacheConfig cacheConfig)
Enable in-memory caching for the Flagsmith API.
|
FlagsmithClient.Builder |
withConfiguration(FlagsmithConfig config)
Override default FlagsmithConfig for Flagsmith API.
|
FlagsmithClient.Builder |
withCustomHttpHeaders(HashMap<String,String> customHeaders)
Add custom HTTP headers to the calls.
|
public FlagsmithClient.Builder setApiKey(String apiKey)
apiKey - the api key for environmentpublic FlagsmithClient.Builder setDefaultFlagPredicate(@NonNull @NonNull Predicate<String> defaultFlagPredicate)
If you would like to override this default behaviour, you can use this method. By default it will return false for any flags that it does not recognise.
defaultFlagPredicate - the new predicate to use as default flag boolean valuespublic FlagsmithClient.Builder setDefaultFlagValueFunction(@NonNull @NonNull Function<String,String> defaultFlagValueFunction)
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.
defaultFlagValueFunction - the new function to use as default flag string valuespublic FlagsmithClient.Builder setDefaultFeatureFlags(@NonNull @NonNull Set<String> defaultFeatureFlags)
If you would like the SDK to return a default list of flags with default values, you can set the default flag names with this method. For example: if you set a default flag with the name "my-flag" using setDefaultFeatureFlags(["my-flag"]), and if you call identifyUserWithTraits(...) and the call fails; identifyUserWithTraits(...) will return a list of flags with 1 flag called "my-flag" and with default values configured with the methods setDefaultFlagPredicate() and setDefaultFlagValueFunction().
Default: empty set;
defaultFeatureFlags - list of flag namespublic FlagsmithClient.Builder enableLogging(FlagsmithLoggerLevel level)
level - log error level.public FlagsmithClient.Builder enableLogging()
public FlagsmithClient.Builder withConfiguration(FlagsmithConfig config)
config - an FlagsmithConfig to override default one.public FlagsmithClient.Builder withApiUrl(String apiUrl)
apiUrl - the new base URI for the API.public FlagsmithClient.Builder withCustomHttpHeaders(HashMap<String,String> customHeaders)
customHeaders - headers.public FlagsmithClient.Builder withCache(FlagsmithCacheConfig cacheConfig)
If no other cache configuration is set, the Caffeine defaults will be used, i.e. no limit
cacheConfig - an FlagsmithCacheConfig.public FlagsmithClient build()
Copyright © 2022. All rights reserved.