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, JsonObject)
  • 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

  • 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
    • builder

      public static <ValueType> FeatureResult.FeatureResultBuilder<ValueType> builder()
    • getValue

      @Nullable public Object getValue()
      The assigned value of the feature
    • getSource

      @Nullable public FeatureResultSource getSource()
      One of "unknownFeature", "defaultValue", "force", "experiment", "cyclicPrerequisite" or "prerequisite"
    • getExperiment

      @Nullable public Experiment<ValueType> getExperiment()
      When source is "experiment", this will be the Experiment object used
    • getExperimentResult

      @Nullable public ExperimentResult<ValueType> getExperimentResult()
      When source is "experiment", this will be an ExperimentResult object
    • getRuleId

      @Nullable public String getRuleId()
      Unique identifier of rule
    • setValue

      public void setValue(@Nullable Object value)
      The assigned value of the feature
    • setSource

      public void setSource(@Nullable FeatureResultSource source)
      One of "unknownFeature", "defaultValue", "force", "experiment", "cyclicPrerequisite" or "prerequisite"
    • setExperiment

      public void setExperiment(@Nullable Experiment<ValueType> experiment)
      When source is "experiment", this will be the Experiment object used
    • setExperimentResult

      public void setExperimentResult(@Nullable ExperimentResult<ValueType> experimentResult)
      When source is "experiment", this will be an ExperimentResult object
    • setRuleId

      public void setRuleId(@Nullable String ruleId)
      Unique identifier of rule
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object