Class GBContext.GBContextBuilder

java.lang.Object
growthbook.sdk.java.GBContext.GBContextBuilder
Enclosing class:
GBContext

public static class GBContext.GBContextBuilder extends Object
The builder class to help create a context. You can use GBContext.builder() or the GBContext constructor
  • Method Details

    • attributesJson

      public GBContext.GBContextBuilder attributesJson(@Nullable String attributesJson)
      Parameters:
      attributesJson - User attributes as JSON string
      Returns:
      this.
    • attributes

      public GBContext.GBContextBuilder attributes(@Nullable com.google.gson.JsonObject attributes)
      Parameters:
      attributes - User attributes as JSON Object, either set this or `attributesJson`
      Returns:
      this.
    • featuresJson

      public GBContext.GBContextBuilder featuresJson(@Nullable String featuresJson)
      Parameters:
      featuresJson - Features response as JSON string, or the encrypted payload. Encrypted payload requires `encryptionKey`
      Returns:
      this.
    • features

      public GBContext.GBContextBuilder features(@Nullable com.google.gson.JsonObject features)
      Parameters:
      features - Features response as JSON Object, either set this or `featuresJson`
      Returns:
      this.
    • encryptionKey

      public GBContext.GBContextBuilder encryptionKey(@Nullable String encryptionKey)
      Parameters:
      encryptionKey - Optional encryption key. If this is not null, featuresJson should be an encrypted payload.
      Returns:
      this.
    • enabled

      public GBContext.GBContextBuilder enabled(@Nullable Boolean enabled)
      Parameters:
      enabled - Whether globally all experiments are enabled (default: true)
      Returns:
      this.
    • isQaMode

      public GBContext.GBContextBuilder isQaMode(Boolean isQaMode)
      Parameters:
      isQaMode - If true, random assignment is disabled and only explicitly forced variations are used.
      Returns:
      this.
    • url

      public GBContext.GBContextBuilder url(@Nullable String url)
      Parameters:
      url - A URL string that is used for experiment evaluation, as well as forcing feature values.
      Returns:
      this.
    • allowUrlOverrides

      public GBContext.GBContextBuilder allowUrlOverrides(Boolean 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

      public GBContext.GBContextBuilder trackingCallback(@Nullable TrackingCallback trackingCallback)
      Parameters:
      trackingCallback - A function that takes Experiment and ExperimentResult as arguments.
      Returns:
      this.
    • featureUsageCallback

      public GBContext.GBContextBuilder featureUsageCallback(@Nullable FeatureUsageCallback featureUsageCallback)
      Parameters:
      featureUsageCallback - A function that takes String and FeatureResult as 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

      public GBContext.GBContextBuilder savedGroups(@Nullable com.google.gson.JsonObject savedGroups)
      Returns:
      this.
    • build

      public GBContext build()
    • toString

      public String toString()
      Overrides:
      toString in class Object