Class ConditionalOperators
java.lang.Object
org.springframework.data.mongodb.core.aggregation.ConditionalOperators
Gateway to conditional expressions that evaluate their argument expressions as booleans to a value.
- Since:
- 1.10
- Author:
- Mark Paluch, Christoph Strobl
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Encapsulates the aggregation framework$cond
operator.static class
static class
Encapsulates the aggregation framework$ifNull
operator.static class
AggregationExpression
for$switch
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCreates newAggregationExpression
that evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.ifNull
(AggregationExpression expression) Creates newAggregationExpression
that evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.static ConditionalOperators.Switch
switchCases
(List<ConditionalOperators.Switch.CaseOperator> conditions) Creates newAggregationExpression
that evaluates a series ofConditionalOperators.Switch.CaseOperator
expressions.static ConditionalOperators.Switch
switchCases
(ConditionalOperators.Switch.CaseOperator... conditions) Creates newAggregationExpression
that evaluates a series ofConditionalOperators.Switch.CaseOperator
expressions.Take the field referenced by given fieldReference.when
(AggregationExpression expression) Take the value resulting from the given expression.when
(CriteriaDefinition criteriaDefinition) Take the value resulting from the given criteriaDefinition.
-
Constructor Details
-
ConditionalOperators
public ConditionalOperators()
-
-
Method Details
-
when
Take the field referenced by given fieldReference.- Parameters:
fieldReference
- must not be null.- Returns:
- new instance of
ConditionalOperators.ConditionalOperatorFactory
.
-
when
public static ConditionalOperators.ConditionalOperatorFactory when(AggregationExpression expression) Take the value resulting from the given expression.- Parameters:
expression
- must not be null.- Returns:
- new instance of
ConditionalOperators.ConditionalOperatorFactory
.
-
when
public static ConditionalOperators.ConditionalOperatorFactory when(CriteriaDefinition criteriaDefinition) Take the value resulting from the given criteriaDefinition.- Parameters:
criteriaDefinition
- must not be null.- Returns:
- new instance of
ConditionalOperators.ConditionalOperatorFactory
.
-
ifNull
Creates newAggregationExpression
that 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.- Parameters:
fieldReference
- must not be null.- Returns:
- new instance of
ConditionalOperators.IfNull.ThenBuilder
to createConditionalOperators.IfNull
.
-
ifNull
Creates newAggregationExpression
that 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.- Parameters:
expression
- must not be null.- Returns:
- new instance of
ConditionalOperators.IfNull.ThenBuilder
to createConditionalOperators.IfNull
.
-
switchCases
public static ConditionalOperators.Switch switchCases(ConditionalOperators.Switch.CaseOperator... conditions) Creates newAggregationExpression
that evaluates a series ofConditionalOperators.Switch.CaseOperator
expressions. When it finds an expression which evaluates to true,$switch
executes a specified expression and breaks out of the control flow.- Parameters:
conditions
- must not be null.- Returns:
- new instance of
ConditionalOperators.Switch
.
-
switchCases
public static ConditionalOperators.Switch switchCases(List<ConditionalOperators.Switch.CaseOperator> conditions) Creates newAggregationExpression
that evaluates a series ofConditionalOperators.Switch.CaseOperator
expressions. When it finds an expression which evaluates to true,$switch
executes a specified expression and breaks out of the control flow.- Parameters:
conditions
- must not be null.- Returns:
- new instance of
ConditionalOperators.Switch
.
-