Module spring.data.mongodb
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
Nested ClassesModifier and TypeClassDescriptionstatic classEncapsulates the aggregation framework$condoperator.static classstatic classEncapsulates the aggregation framework$ifNulloperator.static classAggregationExpressionfor$switch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates newAggregationExpressionthat evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.ifNull(AggregationExpression expression) Creates newAggregationExpressionthat evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value.static ConditionalOperators.SwitchswitchCases(List<ConditionalOperators.Switch.CaseOperator> conditions) Creates newAggregationExpressionthat evaluates a series ofConditionalOperators.Switch.CaseOperatorexpressions.static ConditionalOperators.SwitchswitchCases(ConditionalOperators.Switch.CaseOperator... conditions) Creates newAggregationExpressionthat evaluates a series ofConditionalOperators.Switch.CaseOperatorexpressions.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 newAggregationExpressionthat 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.ThenBuilderto createConditionalOperators.IfNull.
-
ifNull
Creates newAggregationExpressionthat 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.ThenBuilderto createConditionalOperators.IfNull.
-
switchCases
public static ConditionalOperators.Switch switchCases(ConditionalOperators.Switch.CaseOperator... conditions) Creates newAggregationExpressionthat evaluates a series ofConditionalOperators.Switch.CaseOperatorexpressions. When it finds an expression which evaluates to true,$switchexecutes 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 newAggregationExpressionthat evaluates a series ofConditionalOperators.Switch.CaseOperatorexpressions. When it finds an expression which evaluates to true,$switchexecutes a specified expression and breaks out of the control flow.- Parameters:
conditions- must not be null.- Returns:
- new instance of
ConditionalOperators.Switch.
-