Skip to content

Document that CodecRegistry instances configured by the application a… #1020

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions driver-core/src/main/com/mongodb/MongoClientSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,15 @@ public Builder credential(final MongoCredential credential) {
/**
* Sets the codec registry
*
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
*
* @param codecRegistry the codec registry
* @return this
* @see MongoClientSettings#getCodecRegistry()
* @see org.bson.codecs.configuration.CodecRegistries
*/
public Builder codecRegistry(final CodecRegistry codecRegistry) {
this.codecRegistry = notNull("codecRegistry", codecRegistry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@ public interface MongoCollection<TDocument> {
/**
* Create a new MongoCollection instance with a different codec registry.
*
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
*
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the collection
* @return a new MongoCollection instance with the different codec registry
* @see org.bson.codecs.configuration.CodecRegistries
*/
MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@ public interface MongoDatabase {
/**
* Create a new MongoDatabase instance with a different codec registry.
*
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
*
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the collection
* @return a new MongoDatabase instance with the different codec registry
* @see org.bson.codecs.configuration.CodecRegistries
*/
MongoDatabase withCodecRegistry(CodecRegistry codecRegistry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@ case class MongoCollection[TResult](private val wrapped: JMongoCollection[TResul
/**
* Create a new MongoCollection instance with a different codec registry.
*
* The { @link CodecRegistry} configured by this method is effectively treated by the driver as an
* instance of { @link CodecProvider}, which { @link CodecRegistry} extends.
* So there is no benefit to defining a class that implements { @link CodecRegistry}. Rather, an
* application should always create { @link CodecRegistry} instances using the factory methods in
* { @link CodecRegistries}.
*
* @param codecRegistry the new { @link org.bson.codecs.configuration.CodecRegistry} for the collection
* @return a new MongoCollection instance with the different codec registry
* @see CodecRegistries
*/
def withCodecRegistry(codecRegistry: CodecRegistry): MongoCollection[TResult] =
MongoCollection(wrapped.withCodecRegistry(codecRegistry))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,15 @@ case class MongoDatabase(private[scala] val wrapped: JMongoDatabase) {
/**
* Create a new MongoDatabase instance with a different codec registry.
*
* The { @link CodecRegistry} configured by this method is effectively treated by the driver as an
* instance of { @link CodecProvider}, which { @link CodecRegistry} extends.
* So there is no benefit to defining a class that implements { @link CodecRegistry}. Rather, an
* application should always create { @link CodecRegistry} instances using the factory methods in
* { @link CodecRegistries}.
*
* @param codecRegistry the new { @link org.bson.codecs.configuration.CodecRegistry} for the collection
* @return a new MongoDatabase instance with the different codec registry
* @see CodecRegistries
*/
def withCodecRegistry(codecRegistry: CodecRegistry): MongoDatabase =
MongoDatabase(wrapped.withCodecRegistry(codecRegistry))
Expand Down
6 changes: 6 additions & 0 deletions driver-sync/src/main/com/mongodb/client/MongoCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,14 @@ public interface MongoCollection<TDocument> {
/**
* Create a new MongoCollection instance with a different codec registry.
*
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
*
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the collection
* @return a new MongoCollection instance with the different codec registry
* @see org.bson.codecs.configuration.CodecRegistries
*/
MongoCollection<TDocument> withCodecRegistry(CodecRegistry codecRegistry);

Expand Down
6 changes: 6 additions & 0 deletions driver-sync/src/main/com/mongodb/client/MongoDatabase.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,14 @@ public interface MongoDatabase {
/**
* Create a new MongoDatabase instance with a different codec registry.
*
* <p>The {@link CodecRegistry} configured by this method is effectively treated by the driver as an instance of
* {@link org.bson.codecs.configuration.CodecProvider}, which {@link CodecRegistry} extends. So there is no benefit to defining
* a class that implements {@link CodecRegistry}. Rather, an application should always create {@link CodecRegistry} instances
* using the factory methods in {@link org.bson.codecs.configuration.CodecRegistries}.</p>
*
* @param codecRegistry the new {@link org.bson.codecs.configuration.CodecRegistry} for the database
* @return a new MongoDatabase instance with the different codec registry
* @see org.bson.codecs.configuration.CodecRegistries
*/
MongoDatabase withCodecRegistry(CodecRegistry codecRegistry);

Expand Down