Package growthbook.sdk.java.model
Class GBContext.GBContextBuilder
java.lang.Object
growthbook.sdk.java.model.GBContext.GBContextBuilder
- Enclosing class:
- GBContext
The builder class to help create a context. You can use
GBContext.builder() or the GBContext constructor-
Method Summary
Modifier and TypeMethodDescriptionallowUrlOverrides(Boolean allowUrlOverrides) attributes(com.google.gson.JsonObject attributes) attributesJson(String attributesJson) build()cacheKeyAttributes(List<String> cacheKeyAttributes) encryptionKey(String encryptionKey) featuresJson(String featuresJson) featureUsageCallback(FeatureUsageCallback featureUsageCallback) forcedVariationsMap(Map<String, ?> forcedVariationsMap) remoteEval(Boolean remoteEval) remoteEvalCacheSize(Integer remoteEvalCacheSize) remoteEvalCacheTtlSeconds(Integer remoteEvalCacheTtlSeconds) savedGroups(com.google.gson.JsonObject savedGroups) stickyBucketAssignmentDocs(Map<String, StickyAssignmentsDocument> stickyBucketAssignmentDocs) stickyBucketIdentifierAttributes(List<String> stickyBucketIdentifierAttributes) stickyBucketService(StickyBucketService stickyBucketService) toString()trackingCallback(TrackingCallback trackingCallback)
-
Method Details
-
attributesJson
- Parameters:
attributesJson- User attributes as JSON string- Returns:
this.
-
attributes
- Parameters:
attributes- User attributes as JSON Object, either set this or `attributesJson`- Returns:
this.
-
featuresJson
- Parameters:
featuresJson- Features response as JSON string, or the encrypted payload. Encrypted payload requires `encryptionKey`- Returns:
this.
-
features
- Parameters:
features- Features response as JSON Object, either set this or `featuresJson`- Returns:
this.
-
encryptionKey
- Parameters:
encryptionKey- Optional encryption key. If this is not null, featuresJson should be an encrypted payload.- Returns:
this.
-
enabled
- Parameters:
enabled- Whether globally all experiments are enabled (default: true)- Returns:
this.
-
isQaMode
- Parameters:
isQaMode- If true, random assignment is disabled and only explicitly forced variations are used.- Returns:
this.
-
url
- Parameters:
url- A URL string that is used for experiment evaluation, as well as forcing feature values.- Returns:
this.
-
allowUrlOverrides
- Parameters:
allowUrlOverrides- Boolean flag to allow URL overrides (default: false)- Returns:
this.
-
forcedVariationsMap
- Parameters:
forcedVariationsMap- Force specific experiments to always assign a specific variation (used for QA)- Returns:
this.
-
trackingCallback
- Parameters:
trackingCallback- A function that takesExperimentandExperimentResultas arguments.- Returns:
this.
-
featureUsageCallback
public GBContext.GBContextBuilder featureUsageCallback(@Nullable FeatureUsageCallback featureUsageCallback) - Parameters:
featureUsageCallback- A function that takesStringandFeatureResultas arguments. A callback that will be invoked every time a feature is viewed. Listen for feature usage events- Returns:
this.
-
stickyBucketService
public GBContext.GBContextBuilder stickyBucketService(@Nullable StickyBucketService stickyBucketService) - Parameters:
stickyBucketService- Service that provide functionality of Sticky Bucketing.- Returns:
this.
-
stickyBucketAssignmentDocs
public GBContext.GBContextBuilder stickyBucketAssignmentDocs(@Nullable Map<String, StickyAssignmentsDocument> stickyBucketAssignmentDocs) - Parameters:
stickyBucketAssignmentDocs- Map of Sticky Bucket documents.- Returns:
this.
-
stickyBucketIdentifierAttributes
public GBContext.GBContextBuilder stickyBucketIdentifierAttributes(@Nullable List<String> stickyBucketIdentifierAttributes) - Parameters:
stickyBucketIdentifierAttributes- List of user's attributes keys.- Returns:
this.
-
savedGroups
- Parameters:
savedGroups- Saved Groups data.- Returns:
this.
-
apiHost
- Parameters:
apiHost- GrowthBook API host for remote evaluation.- Returns:
this.
-
clientKey
- Parameters:
clientKey- GrowthBook SDK client key for remote evaluation.- Returns:
this.
-
remoteEval
- Parameters:
remoteEval- Whether to use remote evaluation.- Returns:
this.
-
cacheKeyAttributes
- Parameters:
cacheKeyAttributes- Attribute names used to build the remote eval cache key.- Returns:
this.
-
remoteEvalCacheSize
- Parameters:
remoteEvalCacheSize- Maximum number of remote eval responses kept in memory.- Returns:
this.
-
remoteEvalCacheTtlSeconds
public GBContext.GBContextBuilder remoteEvalCacheTtlSeconds(@Nullable Integer remoteEvalCacheTtlSeconds) - Returns:
this.
-
build
-
toString
-