Class GrowthBookClient
java.lang.Object
growthbook.sdk.java.multiusermode.GrowthBookClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<ValueType>
FeatureResult<ValueType>evalFeature(String key, Class<ValueType> valueTypeClass, UserContext userContext) getBooleanFeature(FeatureKey<Boolean> featureKey, UserContext userContext) Get a boolean feature value, defaulting tofalsewhen missing or falsy.getBooleanFeature(FeatureKey<Boolean> featureKey, Boolean defaultValue, UserContext userContext) Get a boolean feature value.Returns a read-only snapshot of the current SDK state.getDoubleFeature(FeatureKey<Double> featureKey, Double defaultValue, UserContext userContext) Get a double feature value.<T> FeatureResult<T>getFeature(FeatureKey<T> featureKey, UserContext userContext) Evaluate a feature for a user using a type-safeFeatureKeyinstead of a raw string key.<T> TgetFeatureValue(FeatureKey<T> featureKey, T defaultValue, UserContext userContext) Get a feature value using a typed key, inferring the deserialization class from the key.<ValueType>
ValueTypegetFeatureValue(String featureKey, ValueType defaultValue, Class<ValueType> gsonDeserializableClass, UserContext userContext) getFloatFeature(FeatureKey<Float> featureKey, Float defaultValue, UserContext userContext) Get a float feature value.getIntegerFeature(FeatureKey<Integer> featureKey, Integer defaultValue, UserContext userContext) Get an integer feature value.getStringFeature(FeatureKey<String> featureKey, String defaultValue, UserContext userContext) Get a string feature value.booleanisOff(FeatureKey<?> featureKey, UserContext userContext) Checks whether the feature identified by the typed key evaluates to off for a user.isOff(String featureKey, UserContext userContext) isOn(FeatureKey<?> featureKey, UserContext userContext) Checks whether the feature identified by the typed key evaluates to on for a user.isOn(String featureKey, UserContext userContext) booleanpreloadRemoteEval(UserContext userContext) voidDeprecated.voidvoidrefreshFeatures(RefreshMode refreshMode) Refreshes features using the provided refresh mode.voidrefreshForRemoteEval(RequestBodyForRemoteEval requestBodyForRemoteEval) <ValueType>
ExperimentResult<ValueType>run(Experiment<ValueType> experiment, UserContext userContext) voidsetGlobalAttributes(String attributes) voidsetGlobalForceFeatures(Map<String, Object> forceFeatures) voidsetGlobalForceVariations(Map<String, Integer> forceVariations) voidshutdown()voidsubscribe(ExperimentRunCallback callback)
-
Constructor Details
-
GrowthBookClient
public GrowthBookClient() -
GrowthBookClient
-
-
Method Details
-
getDiagnostics
Returns a read-only snapshot of the current SDK state.- Returns:
- diagnostics snapshot
-
initialize
public boolean initialize() -
setGlobalAttributes
-
setGlobalForceFeatures
-
setGlobalForceVariations
-
refreshFeature
Deprecated. -
refreshFeatures
public void refreshFeatures() -
refreshFeatures
Refreshes features using the provided refresh mode.- Parameters:
refreshMode- refresh behavior to use
-
refreshForRemoteEval
-
preloadRemoteEval
-
evalFeature
public <ValueType> FeatureResult<ValueType> evalFeature(String key, Class<ValueType> valueTypeClass, UserContext userContext) -
isOn
-
isOff
-
getFeatureValue
public <ValueType> ValueType getFeatureValue(String featureKey, ValueType defaultValue, Class<ValueType> gsonDeserializableClass, UserContext userContext) -
getFeature
Evaluate a feature for a user using a type-safeFeatureKeyinstead of a raw string key.As with
evalFeature(String, Class, UserContext), the returned result'sFeatureResult.getValue()is the raw evaluated value (a boxed primitive, or aMap/Listfor object and array features); it is not deserialized into the key's value type. To obtain a deserialized instance of a complex type, usegetFeatureValue(FeatureKey, Object, UserContext).- Type Parameters:
T- feature value type carried by the key- Parameters:
featureKey- typed feature key, e.g.Features.NEW_HOMEuserContext- user context- Returns:
- the feature result
-
isOn
Checks whether the feature identified by the typed key evaluates to on for a user.- Parameters:
featureKey- typed feature keyuserContext- user context- Returns:
- true when the feature is on
-
isOff
Checks whether the feature identified by the typed key evaluates to off for a user.- Parameters:
featureKey- typed feature keyuserContext- user context- Returns:
- true when the feature is off
-
getFeatureValue
Get a feature value using a typed key, inferring the deserialization class from the key.- Type Parameters:
T- feature value type carried by the key- Parameters:
featureKey- typed feature keydefaultValue- value to return when the feature is missing or invaliduserContext- user context- Returns:
- the found value or defaultValue
-
getBooleanFeature
Get a boolean feature value, defaulting tofalsewhen missing or falsy.- Parameters:
featureKey- typed boolean feature keyuserContext- user context- Returns:
- the found value or
false
-
getBooleanFeature
public Boolean getBooleanFeature(FeatureKey<Boolean> featureKey, Boolean defaultValue, UserContext userContext) Get a boolean feature value.- Parameters:
featureKey- typed boolean feature keydefaultValue- value to return when the feature is missing or invaliduserContext- user context- Returns:
- the found value or defaultValue
-
getStringFeature
public String getStringFeature(FeatureKey<String> featureKey, String defaultValue, UserContext userContext) Get a string feature value.- Parameters:
featureKey- typed string feature keydefaultValue- value to return when the feature is missing or invaliduserContext- user context- Returns:
- the found value or defaultValue
-
getIntegerFeature
public Integer getIntegerFeature(FeatureKey<Integer> featureKey, Integer defaultValue, UserContext userContext) Get an integer feature value.- Parameters:
featureKey- typed integer feature keydefaultValue- value to return when the feature is missing or invaliduserContext- user context- Returns:
- the found value or defaultValue
-
getDoubleFeature
public Double getDoubleFeature(FeatureKey<Double> featureKey, Double defaultValue, UserContext userContext) Get a double feature value.- Parameters:
featureKey- typed double feature keydefaultValue- value to return when the feature is missing or invaliduserContext- user context- Returns:
- the found value or defaultValue
-
getFloatFeature
public Float getFloatFeature(FeatureKey<Float> featureKey, Float defaultValue, UserContext userContext) Get a float feature value.- Parameters:
featureKey- typed float feature keydefaultValue- value to return when the feature is missing or invaliduserContext- user context- Returns:
- the found value or defaultValue
-
run
public <ValueType> ExperimentResult<ValueType> run(Experiment<ValueType> experiment, UserContext userContext) -
subscribe
-
shutdown
public void shutdown()
-