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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Expression
cmp(Expression first, Expression 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.static Expression
eq(Expression first, Expression second)
Returns true if the values are equivalent.static Expression
gt(Expression first, Expression second)
Compares two values and returns: true when the first value is greater than the second value.static Expression
gte(Expression first, Expression second)
Compares two values and returns: true when the first value is greater than or equivalent to the second value.static Expression
lt(Expression first, Expression second)
Returns true if the first value is less than the second.static Expression
lte(Expression first, Expression second)
Compares two values and returns: true when the first value is less than or equivalent to the second value.static Expression
ne(Expression first, Expression second)
Returns true if the values are not equivalent.
-
-
-
Method Detail
-
cmp
public static Expression cmp(Expression first, Expression 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 comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $cmp
-
eq
public static Expression eq(Expression first, @Nullable Expression second)
Returns true if the values are equivalent.- Parameters:
first
- an expression for the value to comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $eq
-
gt
public static Expression gt(Expression first, Expression second)
Compares two values and returns:- true when the first value is greater than the second value.
- false when the first value is less than or equivalent to the second value.
- Parameters:
first
- an expression for the value to comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $gt
-
gte
public static Expression gte(Expression first, Expression second)
Compares two values and returns:- true when the first value is greater than or equivalent to the second value.
- false when the first value is less than the second value.
- Parameters:
first
- an expression for the value to comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $gte
-
lt
public static Expression lt(Expression first, Expression second)
Returns true if the first value is less than the second.- Parameters:
first
- an expression for the value to comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $lt
-
lte
public static Expression lte(Expression first, Expression second)
Compares two values and returns:- true when the first value is less than or equivalent to the second value.
- false when the first value is greater than the second value.
- Parameters:
first
- an expression for the value to comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $lte
-
ne
public static Expression ne(Expression first, @Nullable Expression second)
Returns true if the values are not equivalent.- Parameters:
first
- an expression for the value to comparesecond
- an expression yielding the value to check against- Returns:
- the new expression
- MongoDB documentation
- Aggregration Expression: $ne
-
-