Class FeatureResult<ValueType>

java.lang.Object
growthbook.sdk.java.FeatureResult<ValueType>
Type Parameters:
ValueType - value type for the feature

public class FeatureResult<ValueType> extends Object
Results for a IFeatureEvaluator.evaluateFeature(String, GBContext, Class)
  • value (any) - The assigned value of the feature
  • on (boolean) - The assigned value cast to a boolean
  • off (boolean) - The assigned value cast to a boolean and then negated
  • source (enum) - One of "unknownFeature", "defaultValue", "force", or "experiment"
  • experiment (Experiment or null) - When source is "experiment", this will be an Experiment object
  • experimentResult (ExperimentResult or null) - When source is "experiment", this will be an ExperimentResult object
  • Constructor Details

    • FeatureResult

      public FeatureResult()
  • Method Details

    • toJson

      public String toJson()
      Get a Gson JsonElement of the FeatureResult
      Returns:
      a Gson JsonElement
    • isOn

      public Boolean isOn()
      Evaluates to true when the feature is on
      Returns:
      Boolean
    • isOff

      public Boolean isOff()
      Evaluates to true when the feature is off
      Returns:
      Boolean
    • getJson

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

      public static <ValueType> com.google.gson.JsonSerializer<FeatureResult<ValueType>> getSerializer()
      a Gson serializer for FeatureResult
      Type Parameters:
      ValueType - FeatureResult
      Returns:
      Gson serializer