Class 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 dev.morphia.aggregation.expressions.impls.Expression condition​(dev.morphia.aggregation.expressions.impls.Expression condition, dev.morphia.aggregation.expressions.impls.Expression then, dev.morphia.aggregation.expressions.impls.Expression otherwise)
      Evaluates a boolean expression to return one of the two specified return expressions.
      static dev.morphia.aggregation.expressions.impls.IfNull ifNull()
      Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.
      static dev.morphia.aggregation.expressions.impls.SwitchExpression switchExpression()
      Evaluates a series of case expressions.
    • Method Detail

      • condition

        public static dev.morphia.aggregation.expressions.impls.Expression condition​(dev.morphia.aggregation.expressions.impls.Expression condition,
                                                                                     dev.morphia.aggregation.expressions.impls.Expression then,
                                                                                     dev.morphia.aggregation.expressions.impls.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 dev.morphia.aggregation.expressions.impls.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 dev.morphia.aggregation.expressions.impls.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