Class AbstractEvaluator
- java.lang.Object
-
- com.intergral.deep.agent.api.plugin.AbstractEvaluator
-
- All Implemented Interfaces:
IEvaluator
- Direct Known Subclasses:
LazyEvaluator
public abstract class AbstractEvaluator extends Object implements IEvaluator
This allows for common handling for object to boolean expressions.
-
-
Constructor Summary
Constructors Constructor Description AbstractEvaluator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanevaluate(String expression, Map<String,Object> values)Evaluate an expression as a boolean response.static booleanobjectToBoolean(Object obj)Given an input convert to a boolean expression.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.intergral.deep.agent.api.plugin.IEvaluator
evaluateExpression
-
-
-
-
Method Detail
-
evaluate
public boolean evaluate(String expression, Map<String,Object> values)
Description copied from interface:IEvaluatorEvaluate an expression as a boolean response.- Specified by:
evaluatein interfaceIEvaluator- Parameters:
expression- the expression to evaluatevalues- the variables that the expression can evaluate against- Returns:
trueif the expression evaluates to truthy value.- See Also:
objectToBoolean(Object)
-
objectToBoolean
public static boolean objectToBoolean(Object obj)
Given an input convert to a boolean expression.As Java doesn't have inherit truthiness such as JavaScript. We want to simulate it here, we will convert the following to inputs, all other inputs are
true.- null - All null values are
false. - boolean = All booleans are returned as they are.
- 0 = All numbers are
true, except 0 which isfalse - "true" = A string of the value
"true"(ignoring case) istrue, all other strings arefalse.
- Parameters:
obj- the value to convert- Returns:
- the value as a boolean
- See Also:
Boolean.parseBoolean(String)
- null - All null values are
-
-