Class ComparisonExpressions

java.lang.Object
dev.morphia.aggregation.expressions.ComparisonExpressions

public final class ComparisonExpressions extends Object
Defines helper methods for the comparison expressions
Since:
2.0
  • Method Details

    • cmp

      public static Expression cmp(Object first, Object second)
      Returns 0 if the two values are equivalent, 1 if the first value is greater than the second, and -1 if the first value is less than the second.
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $cmp
    • eq

      public static Expression eq(Object first, @Nullable Object second)
      Creates an equality check expression
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $eq
    • gt

      public static Expression gt(Object first, Object second)
      Compares two values and returns:
      1. true when the first value is greater than the second value.
      2. false when the first value is less than or equivalent to the second value.
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $gt
    • gte

      public static Expression gte(Object first, Object second)
      Compares two values and returns:
      1. true when the first value is greater than or equivalent to the second value.
      2. false when the first value is less than the second value.
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $gte
    • lt

      public static Expression lt(Object first, Object second)
      Creates a "less than" comparison.
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $lt
    • lte

      public static Expression lte(Object first, Object second)
      Compares two values and returns:
      1. true when the first value is less than or equivalent to the second value.
      2. false when the first value is greater than the second value.
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $lte
    • ne

      public static Expression ne(Object first, @Nullable Object second)
      Creates an inequality check expression
      Parameters:
      first - an expression for the value to compare
      second - an expression yielding the value to check against
      Returns:
      the new expression
      MongoDB documentation
      Aggregration Expression: $ne