public class ConditionalOperator extends Object implements AggregationExpression
$cond
operator. A ConditionalOperator
allows nested conditions
if-then[if-then-else]-else
using Field
, CriteriaDefinition
or a custom
condition. Replacement values can be either field references
, values of simple MongoDB types or values
that can be converted to a simple MongoDB type.http://docs.mongodb.com/manual/reference/operator/aggregation/cond/
Modifier and Type | Class and Description |
---|---|
static class |
ConditionalOperator.ConditionalExpressionBuilder
Builder for fluent
ConditionalOperator creation. |
static interface |
ConditionalOperator.OtherwiseBuilder |
static interface |
ConditionalOperator.ThenBuilder |
static interface |
ConditionalOperator.WhenBuilder |
Constructor and Description |
---|
ConditionalOperator(CriteriaDefinition condition,
Object thenValue,
Object otherwiseValue)
|
ConditionalOperator(org.bson.Document condition,
Object thenValue,
Object otherwiseValue)
|
ConditionalOperator(Field condition,
Object thenValue,
Object otherwiseValue)
|
Modifier and Type | Method and Description |
---|---|
static ConditionalOperator.ConditionalExpressionBuilder |
newBuilder()
Get a builder that allows fluent creation of
ConditionalOperator . |
org.bson.Document |
toDocument(AggregationOperationContext context)
|
public ConditionalOperator(Field condition, Object thenValue, Object otherwiseValue)
condition
- must not be null.thenValue
- must not be null.otherwiseValue
- must not be null.public ConditionalOperator(CriteriaDefinition condition, Object thenValue, Object otherwiseValue)
condition
- must not be null.thenValue
- must not be null.otherwiseValue
- must not be null.public org.bson.Document toDocument(AggregationOperationContext context)
AggregationExpression
toDocument
in interface AggregationExpression
public static ConditionalOperator.ConditionalExpressionBuilder newBuilder()
ConditionalOperator
.ConditionalOperator.ConditionalExpressionBuilder
.Copyright © 2011-2016–2016 Pivotal Software, Inc.. All rights reserved.