Class ConditionalExpressions
- java.lang.Object
-
- dev.morphia.aggregation.experimental.expressions.ConditionalExpressions
-
public class ConditionalExpressions extends Object
Defines helper methods for the conditional expressions- Since:
- 2.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Expression
condition(Expression condition, Expression then, Expression otherwise)
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
switchExpression()
Evaluates a series of case expressions.
-
-
-
Method Detail
-
condition
public static Expression condition(Expression condition, Expression then, Expression otherwise)
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
public static IfNull 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
- MongoDB documentation
- Aggregration Expression: $ifNull
-
switchExpression
public static SwitchExpression 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
-
-