Module spring.data.mongodb
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
ConstructorsConstructorDescriptionTypeBasedAggregationOperationContext(Class<?> type, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, QueryMapper mapper) Creates a newTypeBasedAggregationOperationContextfor the given type,MappingContextandQueryMapper.TypeBasedAggregationOperationContext(Class<?> type, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, QueryMapper mapper, FieldLookupPolicy lookupPolicy) Creates a newTypeBasedAggregationOperationContextfor the given type,MappingContextandQueryMapper. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated, for removal: This API element is subject to removal in a future version.continueOnMissingFieldReference(Class<?> type) This toggle allows thecontextto use any given field name without checking for its existence.expose(ExposedFields fields) Create a nestedAggregationOperationContextfrom this context that exposesfields.org.bson.codecs.configuration.CodecRegistryGet the underlyingCodecRegistryused by the MongoDB Java driver.Returns theFieldsexposed by the type.org.bson.DocumentgetMappedObject(org.bson.Document document) Returns the mappedDocument, potentially converting the source considering mapping metadata etc.org.bson.DocumentgetMappedObject(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.FieldReferencefor the field with the given name.getReference(Field field) Returns aExposedFields.FieldReferencefor the given field.protected ExposedFields.FieldReferencegetReferenceFor(Field field) Class<?>getType()inheritAndExpose(ExposedFields fields) Create a nestedAggregationOperationContextfrom this context that inherits exposed fields from this context and exposesfields.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.CodecRegistryProvider
getCodecFor, hasCodecFor
-
Constructor Details
-
TypeBasedAggregationOperationContext
public TypeBasedAggregationOperationContext(Class<?> type, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, QueryMapper mapper) Creates a newTypeBasedAggregationOperationContextfor the given type,MappingContextandQueryMapper.- Parameters:
type- must not be null.mappingContext- must not be null.mapper- must not be null.
-
TypeBasedAggregationOperationContext
public TypeBasedAggregationOperationContext(Class<?> type, MappingContext<? extends MongoPersistentEntity<?>, MongoPersistentProperty> mappingContext, QueryMapper mapper, FieldLookupPolicy lookupPolicy) Creates a newTypeBasedAggregationOperationContextfor the given type,MappingContextandQueryMapper.- Parameters:
type- must not be null.mappingContext- must not be null.mapper- must not be null.lookupPolicy- must not be null.- Since:
- 4.3.1
-
-
Method Details
-
getMappedObject
public org.bson.Document getMappedObject(org.bson.Document document) Description copied from interface:AggregationOperationContextReturns the mappedDocument, potentially converting the source considering mapping metadata etc.- Specified by:
getMappedObjectin interfaceAggregationOperationContext- Parameters:
document- will never be null.- Returns:
- must not be null.
-
getMappedObject
Description copied from interface:AggregationOperationContextReturns the mappedDocument, potentially converting the source considering mapping metadata for the given type.- Specified by:
getMappedObjectin interfaceAggregationOperationContext- Parameters:
document- will never be null.type- can be null.- Returns:
- must not be null.
-
getReference
Description copied from interface:AggregationOperationContextReturns aExposedFields.FieldReferencefor the given field.- Specified by:
getReferencein interfaceAggregationOperationContext- Parameters:
field- must not be null.- Returns:
- the
ExposedFields.FieldReferencefor the givenField.
-
getReference
Description copied from interface:AggregationOperationContextReturns theExposedFields.FieldReferencefor the field with the given name.- Specified by:
getReferencein interfaceAggregationOperationContext- Parameters:
name- must not be null or empty.- Returns:
- the
ExposedFields.FieldReferencefor the field with given name.
-
getFields
Description copied from interface:AggregationOperationContextReturns theFieldsexposed by the type. May be a class or an interface. The default implementation usesproperty descriptorsdiscover fields from aClass.- Specified by:
getFieldsin interfaceAggregationOperationContext- Parameters:
type- must not be null.- Returns:
- never null.
- See Also:
-
continueOnMissingFieldReference
@Deprecated(since="4.3.1", forRemoval=true) public AggregationOperationContext continueOnMissingFieldReference()Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:AggregationOperationContextThis toggle allows thecontextto use any given field name without checking for its existence. Typically, theAggregationOperationContextfails when referencing unknown fields, those that are not present in one of the previous stages or the input source, throughout the pipeline.- Specified by:
continueOnMissingFieldReferencein interfaceAggregationOperationContext- Returns:
- a more relaxed
AggregationOperationContext.
-
continueOnMissingFieldReference
This toggle allows thecontextto use any given field name without checking for its existence. Typically, theAggregationOperationContextfails 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:
-
expose
Description copied from interface:AggregationOperationContextCreate a nestedAggregationOperationContextfrom this context that exposesfields.Implementations of
AggregationOperationContextretain theirFieldLookupPolicy. If no policy is specified, then lookup defaults toFieldLookupPolicy.strict().- Specified by:
exposein interfaceAggregationOperationContext- Parameters:
fields- the fields to expose, must not be null.- Returns:
- the new
AggregationOperationContextexposingfields.
-
inheritAndExpose
Description copied from interface:AggregationOperationContextCreate a nestedAggregationOperationContextfrom this context that inherits exposed fields from this context and exposesfields.Implementations of
AggregationOperationContextretain theirFieldLookupPolicy. If no policy is specified, then lookup defaults toFieldLookupPolicy.strict().- Specified by:
inheritAndExposein interfaceAggregationOperationContext- Parameters:
fields- the fields to expose, must not be null.- Returns:
- the new
AggregationOperationContextexposingfields.
-
getReferenceFor
-
getType
-
getCodecRegistry
public org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Description copied from interface:CodecRegistryProviderGet the underlyingCodecRegistryused by the MongoDB Java driver.- Specified by:
getCodecRegistryin interfaceAggregationOperationContext- Specified by:
getCodecRegistryin interfaceCodecRegistryProvider- Returns:
- never null.
-