Class ConditionalExpressions


  • public class ConditionalExpressions
    extends Object
    Defines helper methods for the conditional expressions
    Since:
    2.0
    • 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 evaluate
        then - the expression for the true branch
        otherwise - 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