Package org.springframework.data.mongodb
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.
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 theCodec
registered for the given type or anempty Optional
instead.org.bson.codecs.configuration.CodecRegistry
Get the underlyingCodecRegistry
used by the MongoDB Java driver.default boolean
hasCodecFor
(Class<?> type) Checks if aCodec
is registered for a given type.
-
Method Details
-
getCodecRegistry
org.bson.codecs.configuration.CodecRegistry getCodecRegistry()Get the underlyingCodecRegistry
used by the MongoDB Java driver.- Returns:
- never null.
- Throws:
IllegalStateException
- ifCodecRegistry
cannot be obtained.
-
hasCodecFor
Checks if aCodec
is registered for a given type.- Parameters:
type
- must not be null.- Returns:
- true if
getCodecRegistry()
holds aCodec
for given type. - Throws:
IllegalStateException
- ifCodecRegistry
cannot be obtained.
-
getCodecFor
Get theCodec
registered for the given type or anempty Optional
instead.- Type Parameters:
T
-- Parameters:
type
- must not be null.- Returns:
- never null.
- Throws:
IllegalArgumentException
- if type is null.
-