From fab40fb2da386469c3d7fd0cc6d328e3336b2f65 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Wed, 4 Oct 2023 15:38:22 -0700 Subject: [PATCH 1/2] Update Javadoc for Projections. JAVA-5089 --- .../mongodb/client/model/FindOneAndDeleteOptions.java | 1 + .../mongodb/client/model/FindOneAndReplaceOptions.java | 1 + .../mongodb/client/model/FindOneAndUpdateOptions.java | 1 + .../src/main/com/mongodb/client/model/Projections.java | 9 +++++++-- .../mongodb/reactivestreams/client/FindPublisher.java | 2 ++ .../main/scala/org/mongodb/scala/FindObservable.scala | 1 + .../main/scala/org/mongodb/scala/model/Projections.scala | 9 +++++++-- .../src/main/com/mongodb/client/FindIterable.java | 2 ++ 8 files changed, 22 insertions(+), 4 deletions(-) diff --git a/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java b/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java index b9e92427dbd..3b25cb69692 100644 --- a/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java @@ -59,6 +59,7 @@ public Bson getProjection() { * @param projection the project document, which may be null. * @return this * @mongodb.driver.manual tutorial/project-fields-from-query-results Projection + * @see Projections */ public FindOneAndDeleteOptions projection(@Nullable final Bson projection) { this.projection = projection; diff --git a/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java b/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java index 5f7319d64e3..fe17d4f24bd 100644 --- a/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java @@ -62,6 +62,7 @@ public Bson getProjection() { * @param projection the project document, which may be null. * @return this * @mongodb.driver.manual tutorial/project-fields-from-query-results Projection + * @see Projections */ public FindOneAndReplaceOptions projection(@Nullable final Bson projection) { this.projection = projection; diff --git a/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java b/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java index ce370b88a16..a850bdcc0f2 100644 --- a/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/FindOneAndUpdateOptions.java @@ -64,6 +64,7 @@ public Bson getProjection() { * @param projection the project document, which may be null. * @return this * @mongodb.driver.manual tutorial/project-fields-from-query-results Projection + * @see Projections */ public FindOneAndUpdateOptions projection(@Nullable final Bson projection) { this.projection = projection; diff --git a/driver-core/src/main/com/mongodb/client/model/Projections.java b/driver-core/src/main/com/mongodb/client/model/Projections.java index 6ef7bc99729..c745b933b46 100644 --- a/driver-core/src/main/com/mongodb/client/model/Projections.java +++ b/driver-core/src/main/com/mongodb/client/model/Projections.java @@ -52,8 +52,13 @@ private Projections() { } /** - * Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported - * using the $project aggregation pipeline stage. + * Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the + * $project aggregation pipeline stage. + * + *

+ * Starting from MongoDB 4.4, projection with an expression is also accepted in various find-related methods (e.g., {@code find()}, + * {@code findOneAndReplace()}, {@code findOneAndUpdate()}, {@code findOneAndDelete()}) within the {@code MongoCollection}-based API + * where projection is supported. * * @param fieldName the field name * @param expression the expression diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java index 3ce47cbf17d..d7ec41a1bfb 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/FindPublisher.java @@ -19,6 +19,7 @@ import com.mongodb.CursorType; import com.mongodb.ExplainVerbosity; import com.mongodb.client.model.Collation; +import com.mongodb.client.model.Projections; import com.mongodb.lang.Nullable; import org.bson.BsonValue; import org.bson.Document; @@ -104,6 +105,7 @@ public interface FindPublisher extends Publisher { * @param projection the project document, which may be null. * @return this * @mongodb.driver.manual reference/method/db.collection.find/ Projection + * @see Projections */ FindPublisher projection(@Nullable Bson projection); /** diff --git a/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala b/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala index f12593c9fc8..2d147a42211 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/FindObservable.scala @@ -121,6 +121,7 @@ case class FindObservable[TResult](private val wrapped: FindPublisher[TResult]) * [[https://www.mongodb.com/docs/manual/reference/method/db.collection.find/ Projection]] * @param projection the project document, which may be null. * @return this + * @see [[org.mongodb.scala.model.Projections]] */ def projection(projection: Bson): FindObservable[TResult] = { wrapped.projection(projection) diff --git a/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala b/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala index 989258aaa59..819e7602bc7 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala @@ -32,8 +32,13 @@ import org.mongodb.scala.bson.conversions.Bson object Projections { /** - * Creates a projection of a field whose value is computed from the given expression. Projection with an expression is only supported - * using the `\$project` aggregation pipeline stage. + * Creates a projection of a field whose value is computed from the given expression. Projection with an expression + * can be used in the $project aggregation pipeline stage. + * + *

+ * Starting from MongoDB 4.4, projection with an expression is also accepted in various find-related methods + * (e.g., `find()`, `findOneAndReplace()`, `findOneAndUpdate()`, `findOneAndDelete()`) within the + * `MongoCollection`-based API where projection is supported. * * @param fieldName the field name * @param expression the expression diff --git a/driver-sync/src/main/com/mongodb/client/FindIterable.java b/driver-sync/src/main/com/mongodb/client/FindIterable.java index affabf0df5b..3ea23c178c1 100644 --- a/driver-sync/src/main/com/mongodb/client/FindIterable.java +++ b/driver-sync/src/main/com/mongodb/client/FindIterable.java @@ -19,6 +19,7 @@ import com.mongodb.CursorType; import com.mongodb.ExplainVerbosity; import com.mongodb.client.model.Collation; +import com.mongodb.client.model.Projections; import com.mongodb.lang.Nullable; import org.bson.BsonValue; import org.bson.Document; @@ -96,6 +97,7 @@ public interface FindIterable extends MongoIterable { * @param projection the project document, which may be null. * @return this * @mongodb.driver.manual reference/method/db.collection.find/ Projection + * @see Projections */ FindIterable projection(@Nullable Bson projection); From 9805d845a9862a4c6b0fec616128119c884819dd Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Wed, 4 Oct 2023 16:02:12 -0700 Subject: [PATCH 2/2] Change javadoc structure. JAVA-5089 --- .../com/mongodb/client/model/Projections.java | 19 +++++++++++------ .../org/mongodb/scala/model/Projections.scala | 21 ++++++++++++------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/driver-core/src/main/com/mongodb/client/model/Projections.java b/driver-core/src/main/com/mongodb/client/model/Projections.java index c745b933b46..e92a95abf81 100644 --- a/driver-core/src/main/com/mongodb/client/model/Projections.java +++ b/driver-core/src/main/com/mongodb/client/model/Projections.java @@ -53,12 +53,19 @@ private Projections() { /** * Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the - * $project aggregation pipeline stage. - * - *

- * Starting from MongoDB 4.4, projection with an expression is also accepted in various find-related methods (e.g., {@code find()}, - * {@code findOneAndReplace()}, {@code findOneAndUpdate()}, {@code findOneAndDelete()}) within the {@code MongoCollection}-based API - * where projection is supported. + * following contexts: + *

* * @param fieldName the field name * @param expression the expression diff --git a/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala b/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala index 819e7602bc7..7da4a853544 100644 --- a/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala +++ b/driver-scala/src/main/scala/org/mongodb/scala/model/Projections.scala @@ -32,13 +32,20 @@ import org.mongodb.scala.bson.conversions.Bson object Projections { /** - * Creates a projection of a field whose value is computed from the given expression. Projection with an expression - * can be used in the $project aggregation pipeline stage. - * - *

- * Starting from MongoDB 4.4, projection with an expression is also accepted in various find-related methods - * (e.g., `find()`, `findOneAndReplace()`, `findOneAndUpdate()`, `findOneAndDelete()`) within the - * `MongoCollection`-based API where projection is supported. + * Creates a projection of a field whose value is computed from the given expression. Projection with an expression can be used in the + * following contexts: + *

* * @param fieldName the field name * @param expression the expression