Class TypeBasedAggregationOperationContext
java.lang.Object
org.springframework.data.mongodb.core.aggregation.TypeBasedAggregationOperationContext
- All Implemented Interfaces:
CodecRegistryProvider
,AggregationOperationContext
- Direct Known Subclasses:
RelaxedTypeBasedAggregationOperationContext
public class TypeBasedAggregationOperationContext
extends Object
implements AggregationOperationContext
AggregationOperationContext
aware of a particular type and a MappingContext
to potentially translate
property references into document field names.- Since:
- 1.3
- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorDescriptionTypeBasedAggregationOperationContext
(Class<?> type, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, QueryMapper mapper) Creates a newTypeBasedAggregationOperationContext
for the given type,MappingContext
andQueryMapper
. -
Method Summary
Modifier and TypeMethodDescriptionThis toggle allows thecontext
to use any given field name without checking for its existence.continueOnMissingFieldReference
(Class<?> type) This toggle allows thecontext
to use any given field name without checking for its existence.org.bson.codecs.configuration.CodecRegistry
Get the underlyingCodecRegistry
used by the MongoDB Java driver.Returns theFields
exposed by the type.org.bson.Document
getMappedObject
(org.bson.Document document) Returns the mappedDocument
, potentially converting the source considering mapping metadata etc.org.bson.Document
getMappedObject
(org.bson.Document document, Class<?> type) Returns the mappedDocument
, potentially converting the source considering mapping metadata for the given type.getReference
(String name) Returns theExposedFields.FieldReference
for the field with the given name.getReference
(Field field) Returns aExposedFields.FieldReference
for the given field.protected ExposedFields.FieldReference
getReferenceFor
(Field field) Class<?>
getType()
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.CodecRegistryProvider
getCodecFor, hasCodecFor
-
Constructor Details
-
TypeBasedAggregationOperationContext
public TypeBasedAggregationOperationContext(Class<?> type, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, QueryMapper mapper) Creates a newTypeBasedAggregationOperationContext
for the given type,MappingContext
andQueryMapper
.- Parameters:
type
- must not be null.mappingContext
- must not be null.mapper
- must not be null.
-
-
Method Details
-
getMappedObject
public org.bson.Document getMappedObject(org.bson.Document document) Description copied from interface:AggregationOperationContext
Returns the mappedDocument
, potentially converting the source considering mapping metadata etc.- Specified by:
getMappedObject
in interfaceAggregationOperationContext
- Parameters:
document
- will never be null.- Returns:
- must not be null.
-
getMappedObject
Description copied from interface:AggregationOperationContext
Returns the mappedDocument
, potentially converting the source considering mapping metadata for the given type.- Specified by:
getMappedObject
in interfaceAggregationOperationContext
- Parameters:
document
- will never be null.type
- can be null.- Returns:
- must not be null.
-
getReference
Description copied from interface:AggregationOperationContext
Returns aExposedFields.FieldReference
for the given field.- Specified by:
getReference
in interfaceAggregationOperationContext
- Parameters:
field
- must not be null.- Returns:
- the
ExposedFields.FieldReference
for the givenField
.
-
getReference
Description copied from interface:AggregationOperationContext
Returns theExposedFields.FieldReference
for the field with the given name.- Specified by:
getReference
in interfaceAggregationOperationContext
- Parameters:
name
- must not be null or empty.- Returns:
- the
ExposedFields.FieldReference
for the field with given name.
-
getFields
Description copied from interface:AggregationOperationContext
Returns theFields
exposed by the type. May be a class or an interface. The default implementation usesproperty descriptors
discover fields from aClass
.- Specified by:
getFields
in interfaceAggregationOperationContext
- Parameters:
type
- must not be null.- Returns:
- never null.
- See Also:
-
continueOnMissingFieldReference
Description copied from interface:AggregationOperationContext
This toggle allows thecontext
to use any given field name without checking for its existence. Typically theAggregationOperationContext
fails when referencing unknown fields, those that are not present in one of the previous stages or the input source, throughout the pipeline.- Specified by:
continueOnMissingFieldReference
in interfaceAggregationOperationContext
- Returns:
- a more relaxed
AggregationOperationContext
.
-
continueOnMissingFieldReference
This toggle allows thecontext
to use any given field name without checking for its existence. Typically, theAggregationOperationContext
fails when referencing unknown fields, those that are not present in one of the previous stages or the input source, throughout the pipeline.- Parameters:
type
- The domain type to map fields to.- Returns:
- a more relaxed
AggregationOperationContext
. - Since:
- 3.1
- See Also:
-
getReferenceFor
-
getType
-
getCodecRegistry
public org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Description copied from interface:CodecRegistryProvider
Get the underlyingCodecRegistry
used by the MongoDB Java driver.- Specified by:
getCodecRegistry
in interfaceAggregationOperationContext
- Specified by:
getCodecRegistry
in interfaceCodecRegistryProvider
- Returns:
- never null.
-