RegistryBuilder
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RegistryBuilder.type
Members list
Value members
Concrete methods
Create builder from base registry with custom configuration
Create builder from base registry with custom configuration
Attributes
Create builder from base registry with default configuration
Create builder from base registry with default configuration
Attributes
Extensions
Extensions
Merge two builders, combining their providers and codecs.
Merge two builders, combining their providers and codecs.
Config and base from the left builder are used; only providers and codecs are merged.
Value parameters
- other
-
The builder to merge with
Attributes
- Returns
-
A new builder with combined providers and codecs
- Example
-
val common = baseBuilder.register[Address].register[Person] val full = common ++ specificBuilder
Build the final org.bson.codecs.configuration.CodecRegistry.
Build the final org.bson.codecs.configuration.CodecRegistry.
This is when the actual registry is constructed from all registered codecs and providers. Call this method only once at the end of your configuration chain.
Attributes
Clear the cached temporary registry.
Clear the cached temporary registry.
Mainly useful for testing or debugging. The cache will be rebuilt on next register call.
Attributes
- Returns
-
A new builder with cache cleared
Get the number of explicitly registered codecs.
Get the number of explicitly registered codecs.
Attributes
- Returns
-
Count of codecs added via
withCodecorwithCodecs
Configure with a function - functional approach for flexible configuration.
Configure with a function - functional approach for flexible configuration.
This is the most flexible configuration method, allowing you to transform the configuration using any logic you need.
Value parameters
- f
-
Function to transform the current configuration
Attributes
- Example
-
// Simple configuration builder.configure(_.copy(noneHandling = NoneHandling.Ignore)) // Using helper methods on CodecConfig builder.configure(_.withIgnoreNone) // Conditional configuration builder.configure { config => if (useEncoding) config.withEncodeNone else config.withIgnoreNone }
Get the current codec configuration.
Get the current codec configuration.
Useful for debugging or conditional logic based on current settings.
Attributes
- Returns
-
The current CodecConfig
Switch policy: encode None as BSON null.
Switch policy: encode None as BSON null.
Attributes
Check if a codec is available for a given type.
Check if a codec is available for a given type.
Type parameters
- T
-
The type to check
Attributes
- Returns
-
true if a codec can be obtained for this type
Switch policy: omit None fields entirely from BSON documents.
Switch policy: omit None fields entirely from BSON documents.
Attributes
Check if this builder has a cached registry.
Check if this builder has a cached registry.
Useful for understanding performance characteristics during chained operations.
Attributes
- Returns
-
true if a registry is cached
Check if the registry is empty (no codecs or providers registered).
Check if the registry is empty (no codecs or providers registered).
Attributes
- Returns
-
true if no codecs or providers have been added
Register a single type and immediately build the registry.
Register a single type and immediately build the registry.
Convenience method for the common pattern of registering one type.
Type parameters
- T
-
The type to register
Attributes
- Example
-
given CodecRegistry = MongoClient.DEFAULT_CODEC_REGISTRY.newBuilder.just[User]
Get the number of registered codec providers.
Get the number of registered codec providers.
Each call to register[T] adds one provider.
Attributes
- Returns
-
Count of providers from
registerandregisterAllcalls
Register a type with automatic codec derivation.
Register a type with automatic codec derivation.
Relies on Scala 3 inline macros to auto-generate the BSON codec. Works for nested case classes and sealed hierarchies.
Type parameters
- T
-
The type to register (must be a case class)
Attributes
Batch register multiple types using tuple syntax.
Batch register multiple types using tuple syntax.
This is more efficient than calling register multiple times separately as it builds the temporary registry only once.
Type parameters
- T
-
A tuple of types to register
Attributes
- Example
-
builder.registerAll[(Person, Address, Department)]
Conditionally register a type based on a runtime condition.
Conditionally register a type based on a runtime condition.
Useful for environment-specific or feature-flag based codec registration.
Type parameters
- T
-
The type to register
Value parameters
- condition
-
Whether to register the type
Attributes
- Example
-
builder .registerIf[DebugInfo](isDevelopment) .registerIf[AdminFeature](hasAdminAccess)
Get a summary of the builder's current state.
Get a summary of the builder's current state.
Useful for logging and debugging.
Attributes
- Returns
-
A human-readable summary string
Alias for build. Constructs the final codec registry.
Alias for build. Constructs the final codec registry.
Attributes
- Returns
-
The assembled CodecRegistry
Attempt to get a codec for a given type from the current registry state.
Attempt to get a codec for a given type from the current registry state.
This builds a snapshot registry if needed and attempts to retrieve a codec. Does not cache the result.
Type parameters
- T
-
The type to check
Attributes
- Returns
-
Some(codec) if available, None otherwise
Add a single explicit codec.
Add a single explicit codec.
Useful for value classes or third-party types where automatic derivation is not possible.
Value parameters
- codec
-
The codec to add
Attributes
Add multiple codecs at once.
Add multiple codecs at once.
Value parameters
- codecs
-
Variable number of codecs to add
Attributes
Set the codec configuration directly.
Set the codec configuration directly.
Value parameters
- newConfig
-
The codec configuration to use
Attributes
Add a single codec provider.
Add a single codec provider.
Attributes
Add multiple codec providers at once.
Add multiple codec providers at once.
Value parameters
- providers
-
Variable number of codec providers to add
Attributes
Register multiple types and immediately build the registry.
Register multiple types and immediately build the registry.
Convenience method for batch registration followed by build.
Type parameters
- T
-
A tuple of types to register
Attributes
- Example
-
val registry = baseRegistry.newBuilder.withTypes[(User, Order, Product)]
Create a new builder with custom configuration
Create a new builder with custom configuration
Attributes
Create a new builder from this registry
Create a new builder from this registry