Interface CodecRegistryProvider

All Known Subinterfaces:
AggregationOperationContext, MongoConverter, MongoDatabaseFactory, ReactiveMongoDatabaseFactory
All Known Implementing Classes:
AbstractMongoConverter, MappingMongoConverter, MongoDatabaseFactorySupport, PrefixingDelegatingAggregationOperationContext, RelaxedTypeBasedAggregationOperationContext, SimpleMongoClientDatabaseFactory, SimpleReactiveMongoDatabaseFactory, TestAggregationContext, TypeBasedAggregationOperationContext
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface CodecRegistryProvider
Provider interface to obtain CodecRegistry from the underlying MongoDB Java driver.
Since:
2.1
Author:
Christoph Strobl, Mark Paluch
  • Method Summary

    Modifier and Type
    Method
    Description
    default <T> Optional<org.bson.codecs.Codec<T>>
    getCodecFor(Class<T> type)
    Get the Codec registered for the given type or an empty Optional instead.
    org.bson.codecs.configuration.CodecRegistry
    Get the underlying CodecRegistry used by the MongoDB Java driver.
    default boolean
    hasCodecFor(Class<?> type)
    Checks if a Codec is registered for a given type.
  • Method Details

    • getCodecRegistry

      org.bson.codecs.configuration.CodecRegistry getCodecRegistry()
      Get the underlying CodecRegistry used by the MongoDB Java driver.
      Returns:
      never null.
      Throws:
      IllegalStateException - if CodecRegistry cannot be obtained.
    • hasCodecFor

      default boolean hasCodecFor(Class<?> type)
      Checks if a Codec is registered for a given type.
      Parameters:
      type - must not be null.
      Returns:
      true if getCodecRegistry() holds a Codec for given type.
      Throws:
      IllegalStateException - if CodecRegistry cannot be obtained.
    • getCodecFor

      default <T> Optional<org.bson.codecs.Codec<T>> getCodecFor(Class<T> type)
      Get the Codec registered for the given type or an empty Optional instead.
      Type Parameters:
      T -
      Parameters:
      type - must not be null.
      Returns:
      never null.
      Throws:
      IllegalArgumentException - if type is null.