Class GroupOperation
java.lang.Object
org.springframework.data.mongodb.core.aggregation.GroupOperation
- All Implemented Interfaces:
AggregationOperation,FieldsExposingAggregationOperation
Encapsulates the aggregation framework
$group-operation.
We recommend to use the static factory method Aggregation.group(Fields) instead of creating instances of this
class directly.
- Since:
- 1.3
- Author:
- Sebastian Herold, Thomas Darimont, Oliver Gierke, Gustavo de Geus, Christoph Strobl, Mark Paluch, Sergey Shcherbakov
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation -
Constructor Summary
ConstructorsModifierConstructorDescriptionGroupOperation(Fields fields) Creates a newGroupOperationincluding the givenFields.protectedGroupOperation(GroupOperation groupOperation) Creates a newGroupOperationfrom the givenGroupOperation. -
Method Summary
Modifier and TypeMethodDescriptionaccumulate(ScriptOperators.Accumulator accumulator) Generates anGroupOperation.GroupOperationBuilderfor an$accumulator-expression.Generates anGroupOperation.GroupOperationBuilderfor an$add_to_set-expression for the given value.Generates anGroupOperation.GroupOperationBuilderfor an$add_to_set-expression for the given field-reference.and(String fieldName, AggregationExpression expression) Adds a computed field to theGroupOperation.protected GroupOperationand(org.springframework.data.mongodb.core.aggregation.GroupOperation.Operation operation) Creates a newGroupOperationfrom the current one adding the givenGroupOperation.Operation.Generates anGroupOperation.GroupOperationBuilderfor an$avg-expression for the given field-reference.avg(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilderfor an$avg-expression for the givenAggregationExpression.count()Generates anGroupOperation.GroupOperationBuilderfor a$sum-expression.Generates anGroupOperation.GroupOperationBuilderfor a$first-expression for the given field-reference.first(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilderfor a$first-expression for the givenAggregationExpression.Returns the fields exposed by theAggregationOperation.Return the MongoDB operator that is used for thisAggregationOperation.Generates anGroupOperation.GroupOperationBuilderfor an$last-expression for the given field-reference.last(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilderfor an$last-expression for the givenAggregationExpression.Generates anGroupOperation.GroupOperationBuilderfor an$max-expression that for the given field-reference.max(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilderfor an$max-expression that for the givenAggregationExpression.Generates anGroupOperation.GroupOperationBuilderfor an$min-expression that for the given field-reference.min(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilderfor an$min-expression that for the givenAggregationExpression.Generates anGroupOperation.GroupOperationBuilderfor an$push-expression for the given value.Generates anGroupOperation.GroupOperationBuilderfor an$push-expression for the given field-reference.Generates anGroupOperation.GroupOperationBuilderfor an$stdDevPop-expression that for the given field-reference.Generates anGroupOperation.GroupOperationBuilderfor an$stdDevPop-expression that for the givenAggregationExpression.stdDevSamp(String reference) Generates anGroupOperation.GroupOperationBuilderfor an$stdDevSamp-expression that for the given field-reference.Generates anGroupOperation.GroupOperationBuilderfor an$stdDevSamp-expression that for the givenAggregationExpression.Generates anGroupOperation.GroupOperationBuilderfor a$sum-expression for the given field-reference.sum(AggregationExpression expr) Generates anGroupOperation.GroupOperationBuilderfor an$sum-expression for the givenAggregationExpression.org.bson.DocumenttoDocument(AggregationOperationContext context) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.mongodb.core.aggregation.AggregationOperation
toPipelineStagesMethods inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
inheritsFields
-
Constructor Details
-
GroupOperation
Creates a newGroupOperationincluding the givenFields.- Parameters:
fields- must not be null.
-
GroupOperation
Creates a newGroupOperationfrom the givenGroupOperation.- Parameters:
groupOperation- must not be null.
-
-
Method Details
-
and
protected GroupOperation and(org.springframework.data.mongodb.core.aggregation.GroupOperation.Operation operation) Creates a newGroupOperationfrom the current one adding the givenGroupOperation.Operation.- Parameters:
operation- must not be null.- Returns:
-
count
Generates anGroupOperation.GroupOperationBuilderfor a$sum-expression.Count expressions are emulated via
$sum: 1.- Returns:
-
sum
Generates anGroupOperation.GroupOperationBuilderfor a$sum-expression for the given field-reference.- Parameters:
reference-- Returns:
-
sum
Generates anGroupOperation.GroupOperationBuilderfor an$sum-expression for the givenAggregationExpression.- Parameters:
expr- must not be null.- Returns:
- new instance of
GroupOperation.GroupOperationBuilder. Never null. - Throws:
IllegalArgumentException- whenexpris null.- Since:
- 1.10.8
-
addToSet
Generates anGroupOperation.GroupOperationBuilderfor an$add_to_set-expression for the given field-reference.- Parameters:
reference-- Returns:
-
addToSet
Generates anGroupOperation.GroupOperationBuilderfor an$add_to_set-expression for the given value.- Parameters:
value-- Returns:
-
last
Generates anGroupOperation.GroupOperationBuilderfor an$last-expression for the given field-reference.- Parameters:
reference-- Returns:
-
last
Generates anGroupOperation.GroupOperationBuilderfor an$last-expression for the givenAggregationExpression.- Parameters:
expr-- Returns:
-
first
Generates anGroupOperation.GroupOperationBuilderfor a$first-expression for the given field-reference.- Parameters:
reference-- Returns:
-
first
Generates anGroupOperation.GroupOperationBuilderfor a$first-expression for the givenAggregationExpression.- Parameters:
expr-- Returns:
-
avg
Generates anGroupOperation.GroupOperationBuilderfor an$avg-expression for the given field-reference.- Parameters:
reference-- Returns:
-
avg
Generates anGroupOperation.GroupOperationBuilderfor an$avg-expression for the givenAggregationExpression.- Parameters:
expr-- Returns:
-
push
Generates anGroupOperation.GroupOperationBuilderfor an$push-expression for the given field-reference.- Parameters:
reference-- Returns:
-
push
Generates anGroupOperation.GroupOperationBuilderfor an$push-expression for the given value.- Parameters:
value-- Returns:
-
min
Generates anGroupOperation.GroupOperationBuilderfor an$min-expression that for the given field-reference.- Parameters:
reference-- Returns:
-
min
Generates anGroupOperation.GroupOperationBuilderfor an$min-expression that for the givenAggregationExpression.- Parameters:
expr-- Returns:
-
max
Generates anGroupOperation.GroupOperationBuilderfor an$max-expression that for the given field-reference.- Parameters:
reference-- Returns:
-
max
Generates anGroupOperation.GroupOperationBuilderfor an$max-expression that for the givenAggregationExpression.- Parameters:
expr-- Returns:
-
stdDevSamp
Generates anGroupOperation.GroupOperationBuilderfor an$stdDevSamp-expression that for the given field-reference.- Parameters:
reference- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
stdDevSamp
Generates anGroupOperation.GroupOperationBuilderfor an$stdDevSamp-expression that for the givenAggregationExpression.- Parameters:
expr- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
stdDevPop
Generates anGroupOperation.GroupOperationBuilderfor an$stdDevPop-expression that for the given field-reference.- Parameters:
reference- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
stdDevPop
Generates anGroupOperation.GroupOperationBuilderfor an$stdDevPop-expression that for the givenAggregationExpression.- Parameters:
expr- must not be null.- Returns:
- never null.
- Since:
- 1.10
-
accumulate
Generates anGroupOperation.GroupOperationBuilderfor an$accumulator-expression.- Parameters:
accumulator- must not be null.- Returns:
- never null.
- Since:
- 3.2
-
and
Adds a computed field to theGroupOperation.- Parameters:
expression- must not be null.- Returns:
- never null.
- Since:
- 4.0
-
getFields
Description copied from interface:FieldsExposingAggregationOperationReturns the fields exposed by theAggregationOperation.- Specified by:
getFieldsin interfaceFieldsExposingAggregationOperation- Returns:
- will never be null.
-
toDocument
Description copied from interface:AggregationOperation- Specified by:
toDocumentin interfaceAggregationOperation- Parameters:
context- theAggregationOperationContextto operate within. Must not be null.- Returns:
- the Document
-
getOperator
Description copied from interface:AggregationOperationReturn the MongoDB operator that is used for thisAggregationOperation. Aggregation operations should implement this method to avoid document rendering.- Specified by:
getOperatorin interfaceAggregationOperation- Returns:
- the operator used for this
AggregationOperation.
-