Class ExpressionProcessor
java.lang.Object
io.camunda.zeebe.engine.processing.common.ExpressionProcessor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic final class -
Constructor Summary
ConstructorsConstructorDescriptionExpressionProcessor(ExpressionLanguage expressionLanguage, ExpressionProcessor.EvaluationContextLookup lookup) -
Method Summary
Modifier and TypeMethodDescriptionevaluateAnyExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result no matter the type.evaluateArrayExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as a list.evaluateArrayOfStringsExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as a list of strings.evaluateBooleanExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as boolean.evaluateDateTimeExpression(Expression expression, Long scopeKey) Evaluates the given expression and returns the result as ZonedDateTime.evaluateDateTimeExpression(Expression expression, Long scopeKey, boolean isNullable) Evaluates the given expression and returns the result asOptional.evaluateIntegerExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as int.evaluateIntervalExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as an Interval.evaluateLongExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as long.evaluateMessageCorrelationKeyExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as String.evaluateStringExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as string.evaluateStringExpressionAsDirectBuffer(Expression expression, long scopeKey) Evaluates the given expression and returns the result as string wrapped inDirectBuffer.evaluateVariableMappingExpression(Expression expression, long scopeKey) Evaluates the given expression of a variable mapping and returns the result as buffer.withPrimaryContext(EvaluationContext primaryContext) Returns a newExpressionProcessorinstance.withSecondaryContext(EvaluationContext secondaryContext) Returns a newExpressionProcessorinstance.
-
Constructor Details
-
ExpressionProcessor
public ExpressionProcessor(ExpressionLanguage expressionLanguage, ExpressionProcessor.EvaluationContextLookup lookup)
-
-
Method Details
-
withPrimaryContext
Returns a newExpressionProcessorinstance. This new instance will useprimaryContextfor all lookups. Only if it doesn't find a variable inprimaryContext, it will lookup variables in the evaluation context ofthisevaluation processor- Parameters:
primaryContext- new top level evaluation context- Returns:
- new instance which uses
primaryContextas new top level evaluation context
-
withSecondaryContext
Returns a newExpressionProcessorinstance. This new instance will usesecondaryContextfor all lookups which it cannot find in its primary evaluation context- Parameters:
secondaryContext- fallback evaluation context- Returns:
- new instance which uses
secondaryContextas fallback
-
evaluateStringExpression
Evaluates the given expression and returns the result as string. If the evaluation fails or the result is not a string then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as string, or a failure
-
evaluateStringExpressionAsDirectBuffer
public Either<Failure,org.agrona.DirectBuffer> evaluateStringExpressionAsDirectBuffer(Expression expression, long scopeKey) Evaluates the given expression and returns the result as string wrapped inDirectBuffer. If the evaluation fails or the result is not a string then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as buffer, or a failure
-
evaluateLongExpression
Evaluates the given expression and returns the result as long. If the evaluation fails or the result is not a number then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as long, or a failure
-
evaluateBooleanExpression
Evaluates the given expression and returns the result as boolean. If the evaluation fails or the result is not a boolean then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as boolean, or a failure
-
evaluateIntervalExpression
Evaluates the given expression and returns the result as an Interval. If the evaluation fails or the result is not an interval then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as interval or a failure
-
evaluateDateTimeExpression
public Either<Failure,ZonedDateTime> evaluateDateTimeExpression(Expression expression, Long scopeKey) Evaluates the given expression and returns the result as ZonedDateTime. If the evaluation fails or the result is not a ZonedDateTime then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as ZonedDateTime or a failure
- Throws:
ExpressionProcessor.EvaluationException- if expression evaluation failed
-
evaluateDateTimeExpression
public Either<Failure,Optional<ZonedDateTime>> evaluateDateTimeExpression(Expression expression, Long scopeKey, boolean isNullable) Evaluates the given expression and returns the result asOptional. By using theisNullableflag, it is also possible to control the behavior if a given expression evaluates to an empty String or null.A failure is returned if the expression evaluation fails, or the result is not a valid ZonedDateTime String. If the
isNullableflag is set totrue, an expression that evaluated to empty String or null is not considered a failure, but returns anOptional.empty()that needs to be handled by the caller of this method.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)isNullable- set totrueto ignore empty String or null values instead of returning a failure- Returns:
- either the evaluation result as ZonedDateTime or a failure
- Throws:
ExpressionProcessor.EvaluationException- if expression evaluation failed
-
evaluateAnyExpression
public Either<Failure,org.agrona.DirectBuffer> evaluateAnyExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result no matter the type.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as buffer, or a failure if the evaluation fails
-
evaluateArrayExpression
public Either<Failure,List<org.agrona.DirectBuffer>> evaluateArrayExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as a list. The entries of the list are encoded in MessagePack and can have any type.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as a list, or a failure if the evaluation fails
-
evaluateArrayOfStringsExpression
public Either<Failure,List<String>> evaluateArrayOfStringsExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as a list of strings.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as a list of regular strings, or a failure if the evaluation fails
-
evaluateMessageCorrelationKeyExpression
public Either<Failure,String> evaluateMessageCorrelationKeyExpression(Expression expression, long scopeKey) Evaluates the given expression and returns the result as String. If the evaluation result is a number it is automatically converted to a string.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as String, or a failure if the evaluation fails
-
evaluateIntegerExpression
Evaluates the given expression and returns the result as int. If the evaluation fails or the result is not a number then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as int, or a failure
-
evaluateVariableMappingExpression
public Either<Failure,org.agrona.DirectBuffer> evaluateVariableMappingExpression(Expression expression, long scopeKey) Evaluates the given expression of a variable mapping and returns the result as buffer. If the evaluation fails or the result is not a context then a failure is returned.- Parameters:
expression- the expression to evaluatescopeKey- the scope to load the variables from (a negative key is intended to imply an empty variable context)- Returns:
- either the evaluation result as buffer, or a failure
-