Class ConditionalExpressions
java.lang.Object
dev.morphia.aggregation.expressions.ConditionalExpressions
Defines helper methods for the conditional expressions
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic Expression
Evaluates a boolean expression to return one of the two specified return expressions.static IfNull
ifNull()
Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.static SwitchExpression
Evaluates a series of case expressions.
-
Method Details
-
condition
Evaluates a boolean expression to return one of the two specified return expressions.- Parameters:
condition
- the condition to evaluatethen
- the expression for the true branchotherwise
- the expresion for the else branch- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $cond
-
ifNull
Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value. If the expression evaluates to a null value, including instances of undefined values or missing fields, returns the value of the replacement expression.- Returns:
- the new expression
- Since server release
- 5.0
- MongoDB documentation
- Aggregration Expression: $ifNull
-
switchExpression
Evaluates a series of case expressions. When it finds an expression which evaluates to true, $switch executes a specified expression and breaks out of the control flow.- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $switch
-