Skip to content
Open
17 changes: 17 additions & 0 deletions lib/src/main/java/growthbook/sdk/java/GrowthBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ public <ValueType> FeatureResult<ValueType> evalFeature(String key, Class<ValueT
return featureEvaluator.evaluateFeature(key, getEvaluationContext(), valueTypeClass);
}

/**
* Evaluates a batch of features reusing a single {@link EvaluationContext}, so shared
* setup (attribute state, global context references) is not repeated per feature.
*
* @param featureKeys the feature keys to evaluate
* @param valueTypeClass the expected value type (typically {@code Object.class} for mixed types)
* @param <ValueType> the result value type
* @return a map from feature key to its {@link FeatureResult}
*/
@Override
public <ValueType> Map<String, FeatureResult<ValueType>> evalFeatures(
List<String> featureKeys,
Class<ValueType> valueTypeClass
) {
return featureEvaluator.evaluateFeatures(featureKeys, getEvaluationContext(), valueTypeClass);
}

/**
* Update the user's attributes
*
Expand Down
12 changes: 12 additions & 0 deletions lib/src/main/java/growthbook/sdk/java/IGrowthBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import growthbook.sdk.java.model.FeatureResult;
import growthbook.sdk.java.stickyBucketing.StickyBucketService;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;

interface IGrowthBook {

Expand All @@ -20,6 +22,16 @@ interface IGrowthBook {

<ValueType> FeatureResult<ValueType> evalFeature(String key, Class<ValueType> valueTypeClass);

/**
* Evaluates a batch of features for the current user, reusing a single evaluation context.
*
* @param featureKeys the feature keys to evaluate
* @param valueTypeClass the expected value type (typically {@code Object.class} for mixed types)
* @param <ValueType> the result value type
* @return a map from feature key to its {@link FeatureResult}
*/
<ValueType> Map<String, FeatureResult<ValueType>> evalFeatures(List<String> featureKeys, Class<ValueType> valueTypeClass);

/**
* Update the user's attributes
*
Expand Down
Loading
Loading