Interface ExprEvaluator<T>
- Type Parameters:
T- The return type that is needed by the caller
- All Known Implementing Classes:
GraalJsEvaluator
public interface ExprEvaluator<T>
An evaluator is a scripting helper that knows what its return type will be at runtime. You can create an Evaluator from an environment and a desired return type, then reuse it. Primitive types that can be mapped from the script to the return type should, including
- Double -> Long
- Double -> Integer
- Double -> Float
- Long -> Integer
An evaluator is not threadsafe by default. If you need threadsafe evaluators with similar semantics, wrap it in a ThreadLocal.
-
Method Summary
Modifier and TypeMethodDescriptioneval()Evaluate the provided script, returning the value that it yieldsdefault ExprEvaluator<T> Set the variable environment of the evaluator
-
Method Details
-
eval
T eval()Evaluate the provided script, returning the value that it yields- Returns:
- An object of type T
-
script
- Parameters:
scriptText- script text- Returns:
- this ExprEvaluator
, for method chaining
-
put
Set the variable environment of the evaluator- Parameters:
varName- the variable name to add to the environmentvar- the object to bind to the varname- Returns:
- this ExprEvaluator
, for method chaining
-
put
-