Package org.springframework.data.mongodb
Interface CodecRegistryProvider
- All Known Subinterfaces:
MongoDatabaseFactory,ReactiveMongoDatabaseFactory
- All Known Implementing Classes:
MongoDatabaseFactorySupport,SimpleMongoClientDatabaseFactory,SimpleReactiveMongoDatabaseFactory
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Provider interface to obtain
CodecRegistry from the underlying MongoDB Java driver.- Since:
- 2.1
- Author:
- Christoph Strobl, Mark Paluch
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> Optional<org.bson.codecs.Codec<T>>getCodecFor(Class<T> type) Get theCodecregistered for the given type or anempty Optionalinstead.org.bson.codecs.configuration.CodecRegistryGet the underlyingCodecRegistryused by the MongoDB Java driver.default booleanhasCodecFor(Class<?> type) Checks if aCodecis registered for a given type.
-
Method Details
-
getCodecRegistry
org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Get the underlyingCodecRegistryused by the MongoDB Java driver.- Returns:
- never null.
- Throws:
IllegalStateException- ifCodecRegistrycannot be obtained.
-
hasCodecFor
Checks if aCodecis registered for a given type.- Parameters:
type- must not be null.- Returns:
- true if
getCodecRegistry()holds aCodecfor given type. - Throws:
IllegalStateException- ifCodecRegistrycannot be obtained.
-
getCodecFor
Get theCodecregistered for the given type or anempty Optionalinstead.- Type Parameters:
T-- Parameters:
type- must not be null.- Returns:
- never null.
- Throws:
IllegalArgumentException- if type is null.
-