Package growthbook.sdk.java
Class GBContext
java.lang.Object
growthbook.sdk.java.GBContext
Context object passed into the GrowthBook constructor.
The
builder() is recommended for constructing a Context.
Alternatively, you can use the class's constructor.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThe builder class to help create a context. -
Constructor Summary
ConstructorsConstructorDescriptionGBContext(String attributesJson, String featuresJson, String encryptionKey, Boolean enabled, Boolean isQaMode, String url, Boolean allowUrlOverrides, Map<String, Integer> forcedVariationsMap, TrackingCallback trackingCallback) TheGBContext.GBContextBuilderis recommended for constructing a Context. -
Method Summary
Modifier and TypeMethodDescriptionstatic GBContext.GBContextBuilderbuilder()The builder class to help create a context.voidsetAttributesJson(String attributesJson) You can update the attributes JSON with new user attributes to evaluate against.voidsetFeaturesJson(String featuresJson) You can update the features JSON with new features to evaluate against.
-
Constructor Details
-
GBContext
public GBContext(@Nullable String attributesJson, @Nullable String featuresJson, @Nullable String encryptionKey, @Nullable Boolean enabled, Boolean isQaMode, @Nullable String url, Boolean allowUrlOverrides, @Nullable Map<String, Integer> forcedVariationsMap, @Nullable TrackingCallback trackingCallback) TheGBContext.GBContextBuilderis recommended for constructing a Context. Alternatively, you can use this static method instead of the builder.- Parameters:
attributesJson- User attributes as JSON stringfeaturesJson- Features response as JSON string, or the encrypted payload. Encrypted payload requires `encryptionKey`encryptionKey- Optional encryption key. If this is not null, featuresJson should be an encrypted payload.enabled- Whether globally all experiments are enabled (default: true)isQaMode- If true, random assignment is disabled and only explicitly forced variations are used.url- A URL string that is used for experiment evaluation, as well as forcing feature values.allowUrlOverrides- Boolean flag to allow URL overrides (default: false)forcedVariationsMap- Force specific experiments to always assign a specific variation (used for QA)trackingCallback- A function that takesExperimentandExperimentResultas arguments.
-
-
Method Details
-
setAttributesJson
You can update the attributes JSON with new user attributes to evaluate against.- Parameters:
attributesJson- updated user attributes
-
setFeaturesJson
You can update the features JSON with new features to evaluate against.- Parameters:
featuresJson- updated features
-
builder
The builder class to help create a context. You can use this builder or the constructor- Returns:
GBContext.CustomGBContextBuilder
-