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()encryptionKey(String encryptionKey) featuresJson(String featuresJson) featureUsageCallback(FeatureUsageCallback featureUsageCallback) forcedVariationsMap(Map<String, Integer> forcedVariationsMap) 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
public GBContext.GBContextBuilder forcedVariationsMap(@Nullable Map<String, Integer> 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) - Returns:
this.
-
savedGroups
- Returns:
this.
-
build
-
toString
-