Skip to content

Commit ce79123

Browse files
committed
JAVA-2137: Deprecate property-mutating methods in Mongo class:
* setWriteConcern * setReadPreference * setOptions * resetOptions * addOption * getOptions
1 parent c79876f commit ce79123

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

driver/src/main/com/mongodb/Mongo.java

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,18 @@ public Mongo(
303303
}
304304

305305
/**
306-
* Sets the write concern for this database. Will be used as default for writes to any collection in any database. See the documentation
307-
* for {@link WriteConcern} for more information.
306+
* Sets the default write concern to use for write operations executed on any {@link DBCollection} created indirectly from this
307+
* instance, via a {@link DB} instance created from {@link #getDB(String)}.
308+
*
309+
* <p>
310+
* Note that changes to the default write concern made via this method will NOT affect the write concern of
311+
* {@link com.mongodb.client.MongoDatabase} instances created via {@link MongoClient#getDatabase(String)}
312+
* </p>
308313
*
309314
* @param writeConcern write concern to use
315+
* @deprecated Set the default write concern with either {@link MongoClientURI} or {@link MongoClientOptions}
310316
*/
317+
@Deprecated
311318
public void setWriteConcern(final WriteConcern writeConcern) {
312319
this.writeConcern = writeConcern;
313320
}
@@ -331,11 +338,18 @@ public ReadConcern getReadConcern() {
331338
}
332339

333340
/**
334-
* Sets the read preference for this database. Will be used as default for reads from any collection in any database. See the
335-
* documentation for {@link ReadPreference} for more information.
341+
* Sets the default read preference to use for reads operations executed on any {@link DBCollection} created indirectly from this
342+
* instance, via a {@link DB} instance created from {@link #getDB(String)}.
336343
*
344+
* <p>
345+
* Note that changes to the default read preference made via this method will NOT affect the read preference of
346+
* {@link com.mongodb.client.MongoDatabase} instances created via {@link MongoClient#getDatabase(String)}
347+
* </p>
348+
337349
* @param readPreference Read Preference to use
350+
* @deprecated Set the default read preference with either {@link MongoClientURI} or {@link MongoClientOptions}
338351
*/
352+
@Deprecated
339353
public void setReadPreference(final ReadPreference readPreference) {
340354
this.readPreference = readPreference;
341355
}
@@ -509,35 +523,58 @@ public void slaveOk() {
509523
}
510524

511525
/**
512-
* Set the default query options.
526+
* Set the default query options for reads operations executed on any {@link DBCollection} created indirectly from this
527+
* instance, via a {@link DB} instance created from {@link #getDB(String)}.
528+
*
529+
* <p>
530+
* Note that changes to query options made via this method will NOT affect
531+
* {@link com.mongodb.client.MongoDatabase} instances created via {@link MongoClient#getDatabase(String)}
532+
* </p>
513533
*
514534
* @param options value to be set
535+
* @deprecated Set options on instances of {@link DBCursor}
515536
*/
537+
@Deprecated
516538
public void setOptions(final int options) {
517539
optionHolder.set(options);
518540
}
519541

520542
/**
521-
* Reset the default query options.
543+
* Reset the default query options for reads operations executed on any {@link DBCollection} created indirectly from this
544+
* instance, via a {@link DB} instance created from {@link #getDB(String)}.
545+
*
546+
* @deprecated Reset options instead on instances of {@link DBCursor}
522547
*/
548+
@Deprecated
523549
public void resetOptions() {
524550
optionHolder.reset();
525551
}
526552

527553
/**
528-
* Add the default query option.
554+
* Add the default query option for reads operations executed on any {@link DBCollection} created indirectly from this
555+
* instance, via a {@link DB} instance created from {@link #getDB(String)}.
556+
*
557+
* <p>
558+
* Note that changes to query options made via this method will NOT affect
559+
* {@link com.mongodb.client.MongoDatabase} instances created via {@link MongoClient#getDatabase(String)}
560+
* </p>
529561
*
530562
* @param option value to be added to current options
563+
* @deprecated Add options instead on instances of {@link DBCursor}
531564
*/
565+
@Deprecated
532566
public void addOption(final int option) {
533567
optionHolder.add(option);
534568
}
535569

536570
/**
537-
* Gets the default query options
571+
* Gets the default query options for reads operations executed on any {@link DBCollection} created indirectly from this
572+
* instance, via a {@link DB} instance created from {@link #getDB(String)}.
538573
*
539574
* @return an int representing the options to be used by queries
575+
* @deprecated Get options instead from instances of {@link DBCursor}
540576
*/
577+
@Deprecated
541578
public int getOptions() {
542579
return optionHolder.get();
543580
}

0 commit comments

Comments
 (0)