Class Experiment<ValueType>

java.lang.Object
growthbook.sdk.java.Experiment<ValueType>

public class Experiment<ValueType> extends Object
Defines a single Experiment
  • Constructor Details

  • Method Details

    • toJson

      public String toJson()
      Get a Gson JsonElement of the experiment
      Returns:
      JsonElement
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getJson

      public static <ValueType> com.google.gson.JsonElement getJson(Experiment<ValueType> object)
      Get a Gson JsonElement of the experiment
      Type Parameters:
      ValueType - value type for the experiment
      Parameters:
      object - experiment
      Returns:
      JsonElement
    • builder

      public static <ValueType> Experiment.ExperimentBuilder<ValueType> builder()
    • getKey

      public String getKey()
      The globally unique identifier for the experiment
    • getVariations

      public ArrayList<ValueType> getVariations()
      The different variations to choose between
    • getWeights

      @Nullable public ArrayList<Float> getWeights()
      How to weight traffic between variations. Must add to 1.
    • getIsActive

      @Nullable public Boolean getIsActive()
      If set to false, always return the control (first variation)
    • getCoverage

      public Float getCoverage()
      What percent of users should be included in the experiment (between 0 and 1, inclusive)
    • getConditionJson

      public com.google.gson.JsonObject getConditionJson()
      Optional targeting condition
    • getParentConditions

      @Nullable public ArrayList<ParentCondition> getParentConditions()
      Each item defines a prerequisite where a `condition` must evaluate against a parent feature's value (identified by `id`). If `gate` is true, then this is a blocking feature-level prerequisite; otherwise it applies to the current rule only.
    • getNamespace

      @Deprecated @Nullable public Namespace getNamespace()
      Deprecated.
      A tuple that contains the namespace identifier, plus a range of coverage for the experiment
    • getForce

      public Integer getForce()
      All users included in the experiment will be forced into the specific variation index
    • getHashAttribute

      public String getHashAttribute()
      What user attribute should be used to assign variations (defaults to `id`) All users included in the experiment will be forced into the specific variation index
    • getHashVersion

      @Nullable public Integer getHashVersion()
      The hash version to use (default to 1)
    • getRanges

      @Nullable public ArrayList<BucketRange> getRanges()
      Array of ranges, one per variation
    • getMeta

      @Nullable public ArrayList<VariationMeta> getMeta()
      Meta info about the variations
    • getFilters

      @Nullable public ArrayList<Filter> getFilters()
      Array of filters to apply
    • getSeed

      @Nullable public String getSeed()
      The hash seed to use
    • getName

      @Nullable public String getName()
      Human-readable name for the experiment
    • getPhase

      @Nullable public String getPhase()
      Identifier of the current experiment phase
    • getFallbackAttribute

      @Nullable public String getFallbackAttribute()
      When using sticky bucketing, can be used as a fallback to assign variations
    • getDisableStickyBucketing

      @Nullable public Boolean getDisableStickyBucketing()
      If true, sticky bucketing will be disabled for this experiment. (Note: sticky bucketing is only available if a StickyBucketingService is provided in the Context)
    • getBucketVersion

      @Nullable public Integer getBucketVersion()
      The sticky bucket version number that can be used to force a re-bucketing of users (default to 0)
    • getMinBucketVersion

      @Nullable public Integer getMinBucketVersion()
      Any users with a sticky bucket version less than this will be excluded from the experiment
    • setKey

      public void setKey(String key)
      The globally unique identifier for the experiment
    • setVariations

      public void setVariations(ArrayList<ValueType> variations)
      The different variations to choose between
    • setWeights

      public void setWeights(@Nullable ArrayList<Float> weights)
      How to weight traffic between variations. Must add to 1.
    • setIsActive

      public void setIsActive(@Nullable Boolean isActive)
      If set to false, always return the control (first variation)
    • setCoverage

      public void setCoverage(Float coverage)
      What percent of users should be included in the experiment (between 0 and 1, inclusive)
    • setConditionJson

      public void setConditionJson(com.google.gson.JsonObject conditionJson)
      Optional targeting condition
    • setParentConditions

      public void setParentConditions(@Nullable ArrayList<ParentCondition> parentConditions)
      Each item defines a prerequisite where a `condition` must evaluate against a parent feature's value (identified by `id`). If `gate` is true, then this is a blocking feature-level prerequisite; otherwise it applies to the current rule only.
    • setNamespace

      @Deprecated public void setNamespace(@Nullable Namespace namespace)
      Deprecated.
      A tuple that contains the namespace identifier, plus a range of coverage for the experiment
    • setForce

      public void setForce(Integer force)
      All users included in the experiment will be forced into the specific variation index
    • setHashAttribute

      public void setHashAttribute(String hashAttribute)
      What user attribute should be used to assign variations (defaults to `id`) All users included in the experiment will be forced into the specific variation index
    • setHashVersion

      public void setHashVersion(@Nullable Integer hashVersion)
      The hash version to use (default to 1)
    • setRanges

      public void setRanges(@Nullable ArrayList<BucketRange> ranges)
      Array of ranges, one per variation
    • setMeta

      public void setMeta(@Nullable ArrayList<VariationMeta> meta)
      Meta info about the variations
    • setFilters

      public void setFilters(@Nullable ArrayList<Filter> filters)
      Array of filters to apply
    • setSeed

      public void setSeed(@Nullable String seed)
      The hash seed to use
    • setName

      public void setName(@Nullable String name)
      Human-readable name for the experiment
    • setPhase

      public void setPhase(@Nullable String phase)
      Identifier of the current experiment phase
    • setFallbackAttribute

      public void setFallbackAttribute(@Nullable String fallbackAttribute)
      When using sticky bucketing, can be used as a fallback to assign variations
    • setDisableStickyBucketing

      public void setDisableStickyBucketing(@Nullable Boolean disableStickyBucketing)
      If true, sticky bucketing will be disabled for this experiment. (Note: sticky bucketing is only available if a StickyBucketingService is provided in the Context)
    • setBucketVersion

      public void setBucketVersion(@Nullable Integer bucketVersion)
      The sticky bucket version number that can be used to force a re-bucketing of users (default to 0)
    • setMinBucketVersion

      public void setMinBucketVersion(@Nullable Integer minBucketVersion)
      Any users with a sticky bucket version less than this will be excluded from the experiment
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object