Interface MongoConverter
- All Superinterfaces:
CodecRegistryProvider,org.springframework.data.convert.EntityConverter<MongoPersistentEntity<?>,,MongoPersistentProperty, Object, org.bson.conversions.Bson> org.springframework.data.convert.EntityReader<Object,,org.bson.conversions.Bson> org.springframework.data.convert.EntityWriter<Object,,org.bson.conversions.Bson> MongoWriter<Object>
- All Known Implementing Classes:
AbstractMongoConverter,MappingMongoConverter
public interface MongoConverter
extends org.springframework.data.convert.EntityConverter<MongoPersistentEntity<?>,MongoPersistentProperty,Object,org.bson.conversions.Bson>, MongoWriter<Object>, org.springframework.data.convert.EntityReader<Object,org.bson.conversions.Bson>, CodecRegistryProvider
Central Mongo specific converter interface which combines
MongoWriter and EntityReader.- Author:
- Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch, Ryan Gibb
-
Method Summary
Modifier and TypeMethodDescriptiondefault ObjectConverts the given raw id value into eitherObjectIdorString.default org.bson.codecs.configuration.CodecRegistryGet the underlyingCodecRegistryused by the MongoDB Java driver.org.springframework.data.convert.CustomConversionsReturns theCustomConversionsfor this converter.org.springframework.data.projection.ProjectionFactoryReturns theProjectionFactoryfor this converter.Returns theTypeMapperbeing used to write type information intoDocuments created with that converter.default <S,T> T mapValueToTargetType(S source, Class<T> targetType, DbRefResolver dbRefResolver) Mapping function capable of converting values into a desired target type by eg. extracting the actual java type from a givenBsonValue.<R> Rproject(org.springframework.data.projection.EntityProjection<R, ?> descriptor, org.bson.conversions.Bson bson) Apply a projection toBsonand return the projection return typeR.Methods inherited from interface org.springframework.data.mongodb.CodecRegistryProvider
getCodecFor, hasCodecForMethods inherited from interface org.springframework.data.convert.EntityConverter
getConversionService, getMappingContextMethods inherited from interface org.springframework.data.convert.EntityReader
readMethods inherited from interface org.springframework.data.convert.EntityWriter
writeMethods inherited from interface org.springframework.data.mongodb.core.convert.MongoWriter
convertToMongoType, convertToMongoType, convertToMongoType, toDBRef, toDocumentPointer
-
Method Details
-
getTypeMapper
MongoTypeMapper getTypeMapper()Returns theTypeMapperbeing used to write type information intoDocuments created with that converter.- Returns:
- will never be null.
-
getProjectionFactory
org.springframework.data.projection.ProjectionFactory getProjectionFactory()Returns theProjectionFactoryfor this converter.- Returns:
- will never be null.
- Since:
- 3.4
-
getCustomConversions
org.springframework.data.convert.CustomConversions getCustomConversions()Returns theCustomConversionsfor this converter.- Returns:
- will never be null.
- Since:
- 3.4
-
project
<R> R project(org.springframework.data.projection.EntityProjection<R, ?> descriptor, org.bson.conversions.Bson bson) Apply a projection toBsonand return the projection return typeR.Non-projectingdescriptors fall back toregular object materialization.- Type Parameters:
R-- Parameters:
descriptor- the projection descriptor, must not be null.bson- must not be null.- Returns:
- a new instance of the projection return type
R. - Since:
- 3.4
-
mapValueToTargetType
@Nullable default <S,T> T mapValueToTargetType(S source, Class<T> targetType, DbRefResolver dbRefResolver) Mapping function capable of converting values into a desired target type by eg. extracting the actual java type from a givenBsonValue.- Type Parameters:
S-T-- Parameters:
targetType- must not be null.dbRefResolver- must not be null.- Returns:
- new typed
Function. - Throws:
IllegalArgumentException- if targetType is null.- Since:
- 2.1
-
convertId
Converts the given raw id value into eitherObjectIdorString.- Parameters:
id- can be null.targetType- must not be null.- Returns:
- null if source id is already null.
- Since:
- 2.2
-
getCodecRegistry
default org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Description copied from interface:CodecRegistryProviderGet the underlyingCodecRegistryused by the MongoDB Java driver.- Specified by:
getCodecRegistryin interfaceCodecRegistryProvider- Returns:
- never null.
-