Module spring.data.mongodb
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
Nested ClassesModifier and TypeClassDescriptionstatic classBucketOperationSupport.ExpressionBucketOperationBuilderSupport<B extends BucketOperationSupport.OutputBuilder<B,T>, T extends BucketOperationSupport<T, B>> Builder for SpEL expression-basedBucketOperationSupport.Output.protected static classOutput field that uses a Mongo operation (expression object) to generate an output field value.protected static classEncapsulates an output field in a bucket aggregation stage.static classBucketOperationSupport.OutputBuilder<B extends BucketOperationSupport.OutputBuilder<B,T>, T extends BucketOperationSupport<T, B>> Base class forBucketOperationSupport.Outputbuilders that result in aBucketOperationSupportproviding the builtBucketOperationSupport.Output.protected static classEncapsulatesBucketOperationSupport.Outputs.Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
FieldsExposingAggregationOperation.InheritsFieldsAggregationOperation -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBucketOperationSupport(AggregationExpression groupByExpression) Creates a newBucketOperationSupportgiven agroup-by expression.protectedBucketOperationSupport(BucketOperationSupport<?, ?> operationSupport) Creates a copy ofBucketOperationSupport.protectedBucketOperationSupport(BucketOperationSupport<?, ?> operationSupport, BucketOperationSupport.Outputs outputs) Creates a copy ofBucketOperationSupportand applies the newBucketOperationSupport.Outputs.protectedBucketOperationSupport(Field groupByField) Creates a newBucketOperationSupportgiven agroup-by field. -
Method Summary
Modifier and TypeMethodDescriptionabstract BCreates a newBucketOperationSupportgiven fieldName to add an output field to the resulting bucket documents.abstract BandOutput(AggregationExpression expression) Creates a newBucketOperationSupportgiven anAggregationExpressionto add an output field to the resulting bucket documents.protected TCreates a newBucketOperationSupportgiven to add a count field to the resulting bucket documents.andOutputExpression(String expression, Object... params) Creates a newBucketOperationSupport.ExpressionBucketOperationBuilderSupportgiven a SpEL expression and optional params to add an output field to the resulting bucket documents.Returns the fields exposed by theAggregationOperation.protected abstract TImplementation hook to create a new bucket operation.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
getOperator, toPipelineStagesMethods inherited from interface org.springframework.data.mongodb.core.aggregation.FieldsExposingAggregationOperation
inheritsFields
-
Constructor Details
-
BucketOperationSupport
Creates a newBucketOperationSupportgiven agroup-by field.- Parameters:
groupByField- must not be null.
-
BucketOperationSupport
Creates a newBucketOperationSupportgiven 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 ofBucketOperationSupportand 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.ExpressionBucketOperationBuilderSupportgiven 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.ExpressionBucketOperationBuilderSupportto createBucketOperation.
-
andOutput
Creates a newBucketOperationSupportgiven anAggregationExpressionto 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 newBucketOperationSupportgiven fieldName to add an output field to the resulting bucket documents.BucketOperationSupportexposes accumulation operations that can be applied to fieldName.- Parameters:
fieldName- must not be null or empty.- Returns:
- never null.
-
andOutputCount
Creates a newBucketOperationSupportgiven to add a count field to the resulting bucket documents.- Returns:
- never null.
-
toDocument
Description copied from interface:AggregationOperation- Specified by:
toDocumentin interfaceAggregationOperation- Parameters:
context- theAggregationOperationContextto operate within. Must not be null.- Returns:
- the Document
-
getFields
Description copied from interface:FieldsExposingAggregationOperationReturns the fields exposed by theAggregationOperation.- Specified by:
getFieldsin 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
-