Interface MongoConverter
- All Superinterfaces:
CodecRegistryProvider, EntityConverter<MongoPersistentEntity<?>, MongoPersistentProperty, Object, org.bson.conversions.Bson>, EntityReader<Object, org.bson.conversions.Bson>, EntityWriter<Object, org.bson.conversions.Bson>, MongoWriter<Object>
- All Known Implementing Classes:
AbstractMongoConverter, MappingMongoConverter
public interface MongoConverter
extends EntityConverter<MongoPersistentEntity<?>, MongoPersistentProperty, Object, org.bson.conversions.Bson>, MongoWriter<Object>, 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 @Nullable ObjectConverts the given raw id value into eitherObjectIdorString.default org.bson.codecs.configuration.CodecRegistryGet the underlyingCodecRegistryused by the MongoDB Java driver.Returns theCustomConversionsfor this converter.Returns theProjectionFactoryfor this converter.Returns theTypeMapperbeing used to write type information intoDocuments created with that converter.default <S,T> @Nullable 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(EntityProjection<R, ?> descriptor, org.bson.conversions.Bson bson) Apply a projection toBsonand return the projection return typeR.Methods inherited from interface CodecRegistryProvider
getCodecFor, hasCodecForMethods inherited from interface EntityConverter
getConversionService, getMappingContextMethods inherited from interface EntityReader
readMethods inherited from interface EntityWriter
writeMethods inherited from interface 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
ProjectionFactory getProjectionFactory()Returns theProjectionFactoryfor this converter.- Returns:
- will never be null.
- Since:
- 3.4
-
getCustomConversions
CustomConversions getCustomConversions()Returns theCustomConversionsfor this converter.- Returns:
- will never be null.
- Since:
- 3.4
-
project
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
default <S,T> @Nullable 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
-
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.
-