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 Details

    • getTypeMapper

      MongoTypeMapper getTypeMapper()
      Returns the TypeMapper being used to write type information into Documents created with that converter.
      Returns:
      will never be null.
    • getProjectionFactory

      ProjectionFactory getProjectionFactory()
      Returns the ProjectionFactory for this converter.
      Returns:
      will never be null.
      Since:
      3.4
    • getCustomConversions

      CustomConversions getCustomConversions()
      Returns the CustomConversions for this converter.
      Returns:
      will never be null.
      Since:
      3.4
    • project

      <R> R project(EntityProjection<R,?> descriptor, org.bson.conversions.Bson bson)
      Apply a projection to Bson and return the projection return type R. Non-projecting descriptors fall back to regular 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 given BsonValue.
      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

      @Nullable default Object convertId(@Nullable Object id, Class<?> targetType)
      Converts the given raw id value into either ObjectId or String.
      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: CodecRegistryProvider
      Get the underlying CodecRegistry used by the MongoDB Java driver.
      Specified by:
      getCodecRegistry in interface CodecRegistryProvider
      Returns:
      never null.