Skip to content

Commit 78e1234

Browse files
committed
Added support for comment for operations
JAVA-4369
1 parent 1ca6477 commit 78e1234

File tree

113 files changed

+5258
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+5258
-273
lines changed

driver-core/src/main/com/mongodb/client/model/BulkWriteOptions.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.mongodb.client.model;
1818

1919
import com.mongodb.lang.Nullable;
20+
import org.bson.BsonString;
21+
import org.bson.BsonValue;
2022

2123
/**
2224
* The options to apply to a bulk write.
@@ -26,6 +28,7 @@
2628
public final class BulkWriteOptions {
2729
private boolean ordered = true;
2830
private Boolean bypassDocumentValidation;
31+
private BsonValue comment;
2932

3033
/**
3134
* If true, then when a write fails, return without performing the remaining
@@ -76,11 +79,50 @@ public BulkWriteOptions bypassDocumentValidation(@Nullable final Boolean bypassD
7679
return this;
7780
}
7881

82+
/**
83+
* Returns the comment to send with the query. The default is not to include a comment with the query.
84+
*
85+
* @return the comment
86+
* @since 4.6
87+
* @mongodb.server.release 4.4
88+
*/
89+
@Nullable
90+
public BsonValue getComment() {
91+
return comment;
92+
}
93+
94+
/**
95+
* Sets the comment for this operation. A null value means no comment is set.
96+
*
97+
* @param comment the comment
98+
* @return this
99+
* @since 4.6
100+
* @mongodb.server.release 4.4
101+
*/
102+
public BulkWriteOptions comment(@Nullable final String comment) {
103+
this.comment = comment != null ? new BsonString(comment) : null;
104+
return this;
105+
}
106+
107+
/**
108+
* Sets the comment for this operation. A null value means no comment is set.
109+
*
110+
* @param comment the comment
111+
* @return this
112+
* @since 4.6
113+
* @mongodb.server.release 4.4
114+
*/
115+
public BulkWriteOptions comment(@Nullable final BsonValue comment) {
116+
this.comment = comment;
117+
return this;
118+
}
119+
79120
@Override
80121
public String toString() {
81122
return "BulkWriteOptions{"
82123
+ "ordered=" + ordered
83124
+ ", bypassDocumentValidation=" + bypassDocumentValidation
125+
+ ", comment=" + comment
84126
+ '}';
85127
}
86128
}

driver-core/src/main/com/mongodb/client/model/CountOptions.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.mongodb.client.model;
1818

1919
import com.mongodb.lang.Nullable;
20+
import org.bson.BsonString;
21+
import org.bson.BsonValue;
2022
import org.bson.conversions.Bson;
2123

2224
import java.util.concurrent.TimeUnit;
@@ -36,6 +38,7 @@ public class CountOptions {
3638
private int skip;
3739
private long maxTimeMS;
3840
private Collation collation;
41+
private BsonValue comment;
3942

4043
/**
4144
* Gets the hint to apply.
@@ -175,6 +178,42 @@ public CountOptions collation(@Nullable final Collation collation) {
175178
return this;
176179
}
177180

181+
/**
182+
* @return the comment for this operation. A null value means no comment is set.
183+
* @since 4.6
184+
* @mongodb.server.release 4.4
185+
*/
186+
@Nullable
187+
public BsonValue getComment() {
188+
return comment;
189+
}
190+
191+
/**
192+
* Sets the comment for this operation. A null value means no comment is set.
193+
*
194+
* @param comment the comment
195+
* @return this
196+
* @since 4.6
197+
* @mongodb.server.release 4.4
198+
*/
199+
public CountOptions comment(@Nullable final String comment) {
200+
this.comment = comment == null ? null : new BsonString(comment);
201+
return this;
202+
}
203+
204+
/**
205+
* Sets the comment for this operation. A null value means no comment is set.
206+
*
207+
* @param comment the comment
208+
* @return this
209+
* @since 4.6
210+
* @mongodb.server.release 4.4
211+
*/
212+
public CountOptions comment(@Nullable final BsonValue comment) {
213+
this.comment = comment;
214+
return this;
215+
}
216+
178217
@Override
179218
public String toString() {
180219
return "CountOptions{"
@@ -184,6 +223,7 @@ public String toString() {
184223
+ ", skip=" + skip
185224
+ ", maxTimeMS=" + maxTimeMS
186225
+ ", collation=" + collation
226+
+ ", comment=" + comment
187227
+ '}';
188228
}
189229
}

driver-core/src/main/com/mongodb/client/model/DeleteOptions.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.mongodb.client.model;
1818

1919
import com.mongodb.lang.Nullable;
20+
import org.bson.BsonString;
21+
import org.bson.BsonValue;
2022
import org.bson.conversions.Bson;
2123

2224
/**
@@ -30,6 +32,7 @@ public class DeleteOptions {
3032
private Bson hint;
3133
private String hintString;
3234
private Collation collation;
35+
private BsonValue comment;
3336

3437
/**
3538
* Returns the collation options
@@ -107,12 +110,53 @@ public DeleteOptions hintString(@Nullable final String hint) {
107110
return this;
108111
}
109112

113+
/**
114+
* @return the comment for this operation. A null value means no comment is set.
115+
* @since 4.6
116+
* @mongodb.server.release 4.4
117+
*/
118+
@Nullable
119+
public BsonValue getComment() {
120+
return comment;
121+
}
122+
123+
/**
124+
* Sets the comment for this operation. A null value means no comment is set.
125+
*
126+
* <p>For bulk operations use: {@link BulkWriteOptions#comment(String)}</p>
127+
*
128+
* @param comment the comment
129+
* @return this
130+
* @since 4.6
131+
* @mongodb.server.release 4.4
132+
*/
133+
public DeleteOptions comment(@Nullable final String comment) {
134+
this.comment = comment != null ? new BsonString(comment) : null;
135+
return this;
136+
}
137+
138+
/**
139+
* Sets the comment for this operation. A null value means no comment is set.
140+
*
141+
* <p>For bulk operations use: {@link BulkWriteOptions#comment(BsonValue)}</p>
142+
*
143+
* @param comment the comment
144+
* @return this
145+
* @since 4.6
146+
* @mongodb.server.release 4.4
147+
*/
148+
public DeleteOptions comment(@Nullable final BsonValue comment) {
149+
this.comment = comment;
150+
return this;
151+
}
152+
110153
@Override
111154
public String toString() {
112155
return "DeleteOptions{"
113156
+ "collation=" + collation
114157
+ ", hint=" + hint
115158
+ ", hintString='" + hintString + '\''
159+
+ ", comment=" + comment
116160
+ '}';
117161
}
118162
}

driver-core/src/main/com/mongodb/client/model/FindOneAndDeleteOptions.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.mongodb.client.model;
1818

1919
import com.mongodb.lang.Nullable;
20+
import org.bson.BsonString;
21+
import org.bson.BsonValue;
2022
import org.bson.conversions.Bson;
2123

2224
import java.util.concurrent.TimeUnit;
@@ -37,6 +39,7 @@ public class FindOneAndDeleteOptions {
3739
private Collation collation;
3840
private Bson hint;
3941
private String hintString;
42+
private BsonValue comment;
4043

4144
/**
4245
* Gets a document describing the fields to return for all matching documents.
@@ -186,6 +189,43 @@ public FindOneAndDeleteOptions hintString(@Nullable final String hint) {
186189
return this;
187190
}
188191

192+
193+
/**
194+
* @return the comment for this operation. A null value means no comment is set.
195+
* @since 4.6
196+
* @mongodb.server.release 4.4
197+
*/
198+
@Nullable
199+
public BsonValue getComment() {
200+
return comment;
201+
}
202+
203+
/**
204+
* Sets the comment for this operation. A null value means no comment is set.
205+
*
206+
* @param comment the comment
207+
* @return this
208+
* @since 4.6
209+
* @mongodb.server.release 4.4
210+
*/
211+
public FindOneAndDeleteOptions comment(@Nullable final String comment) {
212+
this.comment = comment != null ? new BsonString(comment) : null;
213+
return this;
214+
}
215+
216+
/**
217+
* Sets the comment for this operation. A null value means no comment is set.
218+
*
219+
* @param comment the comment
220+
* @return this
221+
* @since 4.6
222+
* @mongodb.server.release 4.4
223+
*/
224+
public FindOneAndDeleteOptions comment(@Nullable final BsonValue comment) {
225+
this.comment = comment;
226+
return this;
227+
}
228+
189229
@Override
190230
public String toString() {
191231
return "FindOneAndDeleteOptions{"
@@ -195,6 +235,7 @@ public String toString() {
195235
+ ", collation=" + collation
196236
+ ", hint=" + hint
197237
+ ", hintString='" + hintString + '\''
238+
+ ", comment=" + comment
198239
+ '}';
199240
}
200241
}

driver-core/src/main/com/mongodb/client/model/FindOneAndReplaceOptions.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package com.mongodb.client.model;
1818

1919
import com.mongodb.lang.Nullable;
20+
import org.bson.BsonString;
21+
import org.bson.BsonValue;
2022
import org.bson.conversions.Bson;
2123

2224
import java.util.concurrent.TimeUnit;
@@ -40,6 +42,7 @@ public class FindOneAndReplaceOptions {
4042
private Collation collation;
4143
private Bson hint;
4244
private String hintString;
45+
private BsonValue comment;
4346

4447
/**
4548
* Gets a document describing the fields to return for all matching documents.
@@ -248,6 +251,43 @@ public FindOneAndReplaceOptions hintString(@Nullable final String hint) {
248251
return this;
249252
}
250253

254+
255+
/**
256+
* @return the comment for this operation. A null value means no comment is set.
257+
* @since 4.6
258+
* @mongodb.server.release 4.4
259+
*/
260+
@Nullable
261+
public BsonValue getComment() {
262+
return comment;
263+
}
264+
265+
/**
266+
* Sets the comment for this operation. A null value means no comment is set.
267+
*
268+
* @param comment the comment
269+
* @return this
270+
* @since 4.6
271+
* @mongodb.server.release 4.4
272+
*/
273+
public FindOneAndReplaceOptions comment(@Nullable final String comment) {
274+
this.comment = comment != null ? new BsonString(comment) : null;
275+
return this;
276+
}
277+
278+
/**
279+
* Sets the comment for this operation. A null value means no comment is set.
280+
*
281+
* @param comment the comment
282+
* @return this
283+
* @since 4.6
284+
* @mongodb.server.release 4.4
285+
*/
286+
public FindOneAndReplaceOptions comment(@Nullable final BsonValue comment) {
287+
this.comment = comment;
288+
return this;
289+
}
290+
251291
@Override
252292
public String toString() {
253293
return "FindOneAndReplaceOptions{"
@@ -260,6 +300,7 @@ public String toString() {
260300
+ ", collation=" + collation
261301
+ ", hint=" + hint
262302
+ ", hintString" + hintString
303+
+ ", comment=" + comment
263304
+ '}';
264305
}
265306
}

0 commit comments

Comments
 (0)