Class BucketOperationSupport<T extends BucketOperationSupport<T,B>,B extends BucketOperationSupport.OutputBuilder<B,T>>
java.lang.Object
org.springframework.data.mongodb.core.aggregation.BucketOperationSupport<T,B>
- All Implemented Interfaces:
AggregationOperation
,FieldsExposingAggregationOperation
- Direct Known Subclasses:
BucketAutoOperation
,BucketOperation
public abstract class BucketOperationSupport<T extends BucketOperationSupport<T,B>,B extends BucketOperationSupport.OutputBuilder<B,T>>
extends Object
implements FieldsExposingAggregationOperation
Base class for bucket operations that support output expressions the aggregation framework.
Bucket stages collect documents into buckets and can contribute output fields.
Implementing classes are required to provide an
Bucket stages collect documents into buckets and can contribute output fields.
Implementing classes are required to provide an
BucketOperationSupport.OutputBuilder
.- Since:
- 1.10
- Author:
- Mark Paluch, Christoph Strobl
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
BucketOperationSupport.ExpressionBucketOperationBuilderSupport<B extends BucketOperationSupport.OutputBuilder<B,
T>, T extends BucketOperationSupport<T, B>> Builder for SpEL expression-basedBucketOperationSupport.Output
.protected static class
Output field that uses a Mongo operation (expression object) to generate an output field value.protected static class
Encapsulates an output field in a bucket aggregation stage.static class
BucketOperationSupport.OutputBuilder<B extends BucketOperationSupport.OutputBuilder<B,
T>, T extends BucketOperationSupport<T, B>> Base class forBucketOperationSupport.Output
builders that result in aBucketOperationSupport
providing the builtBucketOperationSupport.Output
.protected static class
EncapsulatesBucketOperationSupport.Output
s.Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation
-
Constructor Summary
ModifierConstructorDescriptionprotected
BucketOperationSupport
(AggregationExpression groupByExpression) Creates a newBucketOperationSupport
given agroup-by expression
.protected
BucketOperationSupport
(BucketOperationSupport<?, ?> operationSupport) Creates a copy ofBucketOperationSupport
.protected
BucketOperationSupport
(BucketOperationSupport<?, ?> operationSupport, BucketOperationSupport.Outputs outputs) Creates a copy ofBucketOperationSupport
and applies the newBucketOperationSupport.Outputs
.protected
BucketOperationSupport
(Field groupByField) Creates a newBucketOperationSupport
given agroup-by field
. -
Method Summary
Modifier and TypeMethodDescriptionabstract B
Creates a newBucketOperationSupport
given fieldName to add an output field to the resulting bucket documents.abstract B
andOutput
(AggregationExpression expression) Creates a newBucketOperationSupport
given anAggregationExpression
to add an output field to the resulting bucket documents.protected T
Creates a newBucketOperationSupport
given to add a count field to the resulting bucket documents.andOutputExpression
(String expression, Object... params) Creates a newBucketOperationSupport.ExpressionBucketOperationBuilderSupport
given a SpEL expression and optional params to add an output field to the resulting bucket documents.Returns the fields exposed by theAggregationOperation
.protected abstract T
Implementation hook to create a new bucket operation.org.bson.Document
toDocument
(AggregationOperationContext context) 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.AggregationOperation
getOperator, toPipelineStages
Methods inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
inheritsFields
-
Constructor Details
-
BucketOperationSupport
Creates a newBucketOperationSupport
given agroup-by field
.- Parameters:
groupByField
- must not be null.
-
BucketOperationSupport
Creates a newBucketOperationSupport
given agroup-by expression
.- Parameters:
groupByExpression
- must not be null.
-
BucketOperationSupport
Creates a copy ofBucketOperationSupport
.- Parameters:
operationSupport
- must not be null.
-
BucketOperationSupport
protected BucketOperationSupport(BucketOperationSupport<?, ?> operationSupport, BucketOperationSupport.Outputs outputs) Creates a copy ofBucketOperationSupport
and applies the newBucketOperationSupport.Outputs
.- Parameters:
operationSupport
- must not be null.outputs
- must not be null.
-
-
Method Details
-
andOutputExpression
public abstract BucketOperationSupport.ExpressionBucketOperationBuilderSupport<B,T> andOutputExpression(String expression, Object... params) Creates a newBucketOperationSupport.ExpressionBucketOperationBuilderSupport
given a SpEL expression and optional params to add an output field to the resulting bucket documents.- Parameters:
expression
- the SpEL expression, must not be null or empty.params
- must not be null- Returns:
- new instance of
BucketOperationSupport.ExpressionBucketOperationBuilderSupport
to createBucketOperation
.
-
andOutput
Creates a newBucketOperationSupport
given anAggregationExpression
to add an output field to the resulting bucket documents.- Parameters:
expression
- the SpEL expression, must not be null or empty.- Returns:
- never null.
-
andOutput
Creates a newBucketOperationSupport
given fieldName to add an output field to the resulting bucket documents.BucketOperationSupport
exposes accumulation operations that can be applied to fieldName.- Parameters:
fieldName
- must not be null or empty.- Returns:
- never null.
-
andOutputCount
Creates a newBucketOperationSupport
given to add a count field to the resulting bucket documents.- Returns:
- never null.
-
toDocument
Description copied from interface:AggregationOperation
- Specified by:
toDocument
in interfaceAggregationOperation
- Parameters:
context
- theAggregationOperationContext
to operate within. Must not be null.- Returns:
- the Document
-
getFields
Description copied from interface:FieldsExposingAggregationOperation
Returns the fields exposed by theAggregationOperation
.- Specified by:
getFields
in interfaceFieldsExposingAggregationOperation
- Returns:
- will never be null.
-
newBucketOperation
Implementation hook to create a new bucket operation.- Parameters:
outputs
- the outputs- Returns:
- the new bucket operation.
-
andOutput
-