Class ConditionalOperators.Cond
java.lang.Object
org.springframework.data.mongodb.core.aggregation.ConditionalOperators.Cond
- All Implemented Interfaces:
AggregationExpression
,MongoExpression
- Enclosing class:
- ConditionalOperators
Encapsulates the aggregation framework
$cond
operator. A ConditionalOperators.Cond
allows nested conditions
if-then[if-then-else]-else
using Field
, CriteriaDefinition
, AggregationExpression
or a custom
condition. Replacement values can be either field references
,
expressions
, values of simple MongoDB types or values that can be converted to a
simple MongoDB type.- Author:
- Mark Paluch, Christoph Strobl
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptionGet a builder that allows fluent creation ofConditionalOperators.Cond
.org.bson.Document
toDocument
(AggregationOperationContext context) Start creating newConditionalOperators.Cond
by providing the field reference used inif
.when
(org.bson.Document booleanExpression) Start creating newConditionalOperators.Cond
by providing the boolean expression used inif
.when
(AggregationExpression expression) when
(CriteriaDefinition criteria) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.core.aggregation.AggregationExpression
toDocument
-
Method Details
-
toDocument
Description copied from interface:AggregationExpression
- Specified by:
toDocument
in interfaceAggregationExpression
- Parameters:
context
- must not be null.- Returns:
- the MongoDB native (
Document
) form of the expression.
-
newBuilder
Get a builder that allows fluent creation ofConditionalOperators.Cond
.- Returns:
- never null.
-
when
Start creating newConditionalOperators.Cond
by providing the boolean expression used inif
.- Parameters:
booleanExpression
- must not be null.- Returns:
- never null.
-
when
- Parameters:
expression
- expression that yields in a boolean result, must not be null.- Returns:
- never null.
-
when
Start creating newConditionalOperators.Cond
by providing the field reference used inif
.- Parameters:
booleanField
- name of a field holding a boolean value, must not be null.- Returns:
- never null.
-
when
- Parameters:
criteria
- criteria to evaluate, must not be null.- Returns:
- the
ConditionalOperators.Cond.ThenBuilder
-