Class ConditionEvaluator
- All Implemented Interfaces:
IConditionEvaluator
Public only so the evaluators package can share it; it is not part of the supported API.
Even so, getPath(com.google.gson.JsonElement, java.lang.String) and isOperatorObject(com.google.gson.JsonElement) keep the exact return types published
in 0.11.0: a return type is part of the JVM method descriptor, so narrowing one is a
NoSuchMethodError for anything linked against that release, which no compiler warns
about. Internally use resolvePath(com.google.gson.JsonElement, java.lang.String) and isOperatorObjectInternal(com.google.gson.JsonElement), which carry
the precise types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionevaluateCondition(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.Resolves a dot-separated path against the attributes.isOperatorObject(com.google.gson.JsonElement object) Returns a boxedBooleanto keep the signature published in 0.11.0: a return type is part of the JVM method descriptor, so narrowing it tobooleanis aNoSuchMethodErrorfor callers compiled against that release.
-
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.- Specified by:
evaluateConditionin interfaceIConditionEvaluator- Parameters:
attributes- A JsonObject of the user attributes to evaluateconditionJson- A JsonObject of the condition- Returns:
- Whether the condition should be true for the user
-
isOperatorObject
Returns a boxedBooleanto keep the signature published in 0.11.0: a return type is part of the JVM method descriptor, so narrowing it tobooleanis aNoSuchMethodErrorfor callers compiled against that release. The value is never null; preferisOperatorObjectInternal(com.google.gson.JsonElement)inside this class.- Parameters:
object- The object to evaluate- Returns:
- true if the object is empty or every key is an operator (starts with
$)
-
getPath
Resolves a dot-separated path against the attributes.Declared as
Objectto keep the signature published in 0.11.0, for the same binary-compatibility reason asisOperatorObject(com.google.gson.JsonElement). Every value it can return is aJsonElementornull; useresolvePath(com.google.gson.JsonElement, java.lang.String)inside this class to get that type without a cast.- Parameters:
attributes- User attributespath- String path, e.g.path.to.something- Returns:
- the value at that path, or
nullif the path doesn't exist
-