Package growthbook.sdk.java.model
Class FeatureRule<ValueType>
java.lang.Object
serializers.SuperTypeToken<ValueType>
growthbook.sdk.java.model.FeatureRule<ValueType>
- Type Parameters:
ValueType
- generic type for the value type for this experiment's variations.
- All Implemented Interfaces:
com.google.gson.JsonDeserializer<FeatureRule<ValueType>>
public class FeatureRule<ValueType>
extends SuperTypeToken<ValueType>
implements com.google.gson.JsonDeserializer<FeatureRule<ValueType>>
Overrides the defaultValue of a Feature based on a set of requirements. Has a number of optional properties
- condition (Condition) - Optional targeting condition
- coverage (number) - What percent of users should be included in the experiment (between 0 and 1, inclusive)
- force (any) - Immediately force a specific value (ignore every other option besides condition and coverage)
- variations (any[]) - Run an experiment (A/B test) and randomly choose between these variations
- key (string) - The globally unique tracking key for the experiment (default to the feature key)
- weights (number[]) - How to weight traffic between variations. Must add to 1.
- namespace (Namespace) - Adds the experiment to a namespace
- hashAttribute (string) - What user attribute should be used to assign variations (defaults to id)
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionFeatureRule
(String id, String key, Float coverage, OptionalField<ValueType> force, ArrayList<ValueType> variations, ArrayList<Float> weights, Namespace namespace, String hashAttribute, com.google.gson.JsonObject condition, ArrayList<ParentCondition> parentConditions, Integer hashVersion, BucketRange range, ArrayList<BucketRange> ranges, ArrayList<VariationMeta> meta, ArrayList<Filter> filters, String seed, String name, String phase, String fallbackAttribute, Boolean disableStickyBucketing, Integer bucketVersion, Integer minBucketVersion, ArrayList<TrackData<ValueType>> tracks) -
Method Summary
Modifier and TypeMethodDescriptionstatic <ValueType>
FeatureRule.FeatureRuleBuilder<ValueType>builder()
deserialize
(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) boolean
A sticky bucket version number that can be used to force a re-bucketing of users (default to 0)com.google.gson.JsonObject
Optional targeting conditionWhat percent of users should be included in the experiment (between 0 and 1, inclusive)If true, sticky bucketing will be disabled for this experiment.When using sticky bucketing, can be used as a fallback to assign variationsArray of filters to apply to the rulegetForce()
Immediately force a specific value (ignore every other option besides condition and coverage)What user attribute should be used to assign variations (defaults to id)The hash version to use (default to 1)getId()
Unique feature rule idgetKey()
The globally unique tracking key for the experiment (default to the feature key)getMeta()
Meta info about the experiment variationsAny users with a sticky bucket version less than this will be excluded from the experimentgetName()
Human-readable name for the experimentDeprecated.Each item defines a prerequisite where a `condition` must evaluate against a parent feature's value (identified by `id`).getPhase()
The phase id of the experimentgetRange()
A more precise version of coverageRanges for experiment variationsgetSeed()
Seed to use for hashingArray of tracking calls to fireRun an experiment (A/B test) and randomly choose between these variationsHow to weight traffic between variations.int
hashCode()
void
setBucketVersion
(Integer bucketVersion) A sticky bucket version number that can be used to force a re-bucketing of users (default to 0)void
setCondition
(com.google.gson.JsonObject condition) Optional targeting conditionvoid
setCoverage
(Float coverage) What percent of users should be included in the experiment (between 0 and 1, inclusive)void
setDisableStickyBucketing
(Boolean disableStickyBucketing) If true, sticky bucketing will be disabled for this experiment.void
setFallbackAttribute
(String fallbackAttribute) When using sticky bucketing, can be used as a fallback to assign variationsvoid
setFilters
(ArrayList<Filter> filters) Array of filters to apply to the rulevoid
setForce
(OptionalField<ValueType> force) Immediately force a specific value (ignore every other option besides condition and coverage)void
setHashAttribute
(String hashAttribute) What user attribute should be used to assign variations (defaults to id)void
setHashVersion
(Integer hashVersion) The hash version to use (default to 1)void
Unique feature rule idvoid
The globally unique tracking key for the experiment (default to the feature key)void
setMeta
(ArrayList<VariationMeta> meta) Meta info about the experiment variationsvoid
setMinBucketVersion
(Integer minBucketVersion) Any users with a sticky bucket version less than this will be excluded from the experimentvoid
Human-readable name for the experimentvoid
setNamespace
(Namespace namespace) Deprecated.void
setParentConditions
(ArrayList<ParentCondition> parentConditions) Each item defines a prerequisite where a `condition` must evaluate against a parent feature's value (identified by `id`).void
The phase id of the experimentvoid
setRange
(BucketRange range) A more precise version of coveragevoid
setRanges
(ArrayList<BucketRange> ranges) Ranges for experiment variationsvoid
Seed to use for hashingvoid
Array of tracking calls to firevoid
setVariations
(ArrayList<ValueType> variations) Run an experiment (A/B test) and randomly choose between these variationsvoid
setWeights
(ArrayList<Float> weights) How to weight traffic between variations.toString()
Methods inherited from class serializers.SuperTypeToken
getType
-
Constructor Details
-
FeatureRule
public FeatureRule(@Nullable String id, @Nullable String key, @Nullable Float coverage, @Nullable OptionalField<ValueType> force, @Nullable ArrayList<ValueType> variations, @Nullable ArrayList<Float> weights, @Nullable Namespace namespace, String hashAttribute, @Nullable com.google.gson.JsonObject condition, @Nullable ArrayList<ParentCondition> parentConditions, @Nullable Integer hashVersion, @Nullable BucketRange range, @Nullable ArrayList<BucketRange> ranges, @Nullable ArrayList<VariationMeta> meta, @Nullable ArrayList<Filter> filters, @Nullable String seed, @Nullable String name, @Nullable String phase, @Nullable String fallbackAttribute, @Nullable Boolean disableStickyBucketing, @Nullable Integer bucketVersion, @Nullable Integer minBucketVersion, @Nullable ArrayList<TrackData<ValueType>> tracks) -
FeatureRule
public FeatureRule()
-
-
Method Details
-
deserialize
public FeatureRule<ValueType> deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) - Specified by:
deserialize
in interfacecom.google.gson.JsonDeserializer<ValueType>
-
builder
-
equals
-
hashCode
public int hashCode() -
getId
Unique feature rule id -
getKey
The globally unique tracking key for the experiment (default to the feature key) -
getCoverage
What percent of users should be included in the experiment (between 0 and 1, inclusive) -
getForce
Immediately force a specific value (ignore every other option besides condition and coverage) -
getVariations
Run an experiment (A/B test) and randomly choose between these variations -
getWeights
How to weight traffic between variations. Must add to 1. -
getNamespace
Deprecated.A tuple that contains the namespace identifier, plus a range of coverage for the experiment. -
getHashAttribute
What user attribute should be used to assign variations (defaults to id) -
getCondition
@Nullable public com.google.gson.JsonObject getCondition()Optional targeting condition -
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. -
getHashVersion
The hash version to use (default to 1) -
getRange
A more precise version of coverage -
getRanges
Ranges for experiment variations -
getMeta
Meta info about the experiment variations -
getFilters
Array of filters to apply to the rule -
getSeed
Seed to use for hashing -
getName
Human-readable name for the experiment -
getPhase
The phase id of the experiment -
getFallbackAttribute
When using sticky bucketing, can be used as a fallback to assign variations -
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
A sticky bucket version number that can be used to force a re-bucketing of users (default to 0) -
getMinBucketVersion
Any users with a sticky bucket version less than this will be excluded from the experiment -
getTracks
Array of tracking calls to fire -
setId
Unique feature rule id -
setKey
The globally unique tracking key for the experiment (default to the feature key) -
setCoverage
What percent of users should be included in the experiment (between 0 and 1, inclusive) -
setForce
Immediately force a specific value (ignore every other option besides condition and coverage) -
setVariations
Run an experiment (A/B test) and randomly choose between these variations -
setWeights
How to weight traffic between variations. Must add to 1. -
setNamespace
Deprecated.A tuple that contains the namespace identifier, plus a range of coverage for the experiment. -
setHashAttribute
What user attribute should be used to assign variations (defaults to id) -
setCondition
public void setCondition(@Nullable com.google.gson.JsonObject condition) Optional targeting condition -
setParentConditions
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. -
setHashVersion
The hash version to use (default to 1) -
setRange
A more precise version of coverage -
setRanges
Ranges for experiment variations -
setMeta
Meta info about the experiment variations -
setFilters
Array of filters to apply to the rule -
setSeed
Seed to use for hashing -
setName
Human-readable name for the experiment -
setPhase
The phase id of the experiment -
setFallbackAttribute
When using sticky bucketing, can be used as a fallback to assign variations -
setDisableStickyBucketing
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
A sticky bucket version number that can be used to force a re-bucketing of users (default to 0) -
setMinBucketVersion
Any users with a sticky bucket version less than this will be excluded from the experiment -
setTracks
Array of tracking calls to fire -
toString
-