Class ConditionEvaluator

java.lang.Object
growthbook.sdk.java.evaluators.ConditionEvaluator

public class ConditionEvaluator extends Object
INTERNAL: Implementation of condition evaluation
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    evaluateCondition(com.google.gson.JsonObject attributes, com.google.gson.JsonObject conditionJson, com.google.gson.JsonObject savedGroups)
    Evaluate a condition for a set of user attributes based on the provided condition.
    getPath(com.google.gson.JsonElement attributes, String path)
    Given attributes and a dot-separated path string,
    isOperatorObject(com.google.gson.JsonElement object)
    This accepts a parsed JSON object as input and returns true if every key in the object starts with $.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConditionEvaluator

      public ConditionEvaluator()
  • Method Details

    • evaluateCondition

      public Boolean evaluateCondition(com.google.gson.JsonObject attributes, com.google.gson.JsonObject conditionJson, @Nullable com.google.gson.JsonObject savedGroups)
      Evaluate a condition for a set of user attributes based on the provided condition. The condition syntax closely resembles MongoDB's syntax. This is defined in the Feature's targeting conditions' Advanced settings.
      Parameters:
      attributes - A JsonObject of the user attributes to evaluate
      conditionJson - A JsonObject of the condition
      Returns:
      Whether the condition should be true for the user
    • isOperatorObject

      public Boolean isOperatorObject(com.google.gson.JsonElement object)
      This accepts a parsed JSON object as input and returns true if every key in the object starts with $.
      Parameters:
      object - The object to evaluate
      Returns:
      if all keys start with $
    • getPath

      @Nullable public Object getPath(com.google.gson.JsonElement attributes, String path)
      Given attributes and a dot-separated path string,
      Parameters:
      attributes - User attributes
      path - String path, e.g. path.to.something
      Returns:
      the value at that path (or null if the path doesn't exist)