Skip to content

Commit 6c4883b

Browse files
vbabaninstIncMale
andauthored
Divide ClientUpdateOptions and ClientDeleteOptions (#1593)
JAVA-5737 --------- Co-authored-by: Valentin Kovalenko <[email protected]>
1 parent 898af58 commit 6c4883b

31 files changed

+812
-208
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ ext {
5959
junitBomVersion = '5.10.2'
6060
logbackVersion = '1.3.14'
6161
graalSdkVersion = '24.0.0'
62+
reflectionsVersion = '0.9.10'
6263
gitVersion = getGitVersion()
6364
}
6465

@@ -128,7 +129,7 @@ configure(scalaProjects) {
128129
testImplementation('org.scalatestplus:junit-4-13_%%:3.2.9.0')
129130
testImplementation('org.scalatestplus:mockito-3-12_%%:3.2.10.0')
130131
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
131-
testImplementation('org.reflections:reflections:0.9.10')
132+
testImplementation("org.reflections:reflections:$reflectionsVersion")
132133
}
133134

134135
test{

driver-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ dependencies {
6060

6161
testImplementation project(':bson').sourceSets.test.output
6262
testImplementation('org.junit.jupiter:junit-jupiter-api')
63+
testImplementation("org.reflections:reflections:$reflectionsVersion")
6364
testRuntimeOnly "io.netty:netty-tcnative-boringssl-static"
6465

6566
classifiers.forEach {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2008-present MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.mongodb.client.model.bulk;
18+
19+
import com.mongodb.client.model.Collation;
20+
import com.mongodb.lang.Nullable;
21+
import org.bson.conversions.Bson;
22+
23+
/**
24+
* The methods declared in this interface are part of the public API of subclasses or sub-interfaces.
25+
*/
26+
interface BaseClientDeleteOptions {
27+
28+
BaseClientDeleteOptions collation(@Nullable Collation collation);
29+
30+
BaseClientDeleteOptions hint(@Nullable Bson hint);
31+
32+
BaseClientDeleteOptions hintString(@Nullable String hintString);
33+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2008-present MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.mongodb.client.model.bulk;
17+
18+
import com.mongodb.client.model.Collation;
19+
import com.mongodb.lang.Nullable;
20+
import org.bson.conversions.Bson;
21+
22+
/**
23+
* The methods declared in this interface are part of the public API of subclasses or sub-interfaces.
24+
*/
25+
interface BaseClientUpdateOptions {
26+
27+
BaseClientUpdateOptions arrayFilters(@Nullable Iterable<? extends Bson> arrayFilters);
28+
29+
BaseClientUpdateOptions collation(@Nullable Collation collation);
30+
31+
BaseClientUpdateOptions hint(@Nullable Bson hint);
32+
33+
BaseClientUpdateOptions hintString(@Nullable String hintString);
34+
35+
BaseClientUpdateOptions upsert(@Nullable Boolean upsert);
36+
}

driver-core/src/main/com/mongodb/client/model/bulk/ClientDeleteOptions.java renamed to driver-core/src/main/com/mongodb/client/model/bulk/ClientDeleteManyOptions.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import com.mongodb.annotations.Sealed;
1919
import com.mongodb.client.model.Collation;
20-
import com.mongodb.internal.client.model.bulk.ConcreteClientDeleteOptions;
20+
import com.mongodb.internal.client.model.bulk.ConcreteClientDeleteManyOptions;
2121
import com.mongodb.lang.Nullable;
2222
import org.bson.conversions.Bson;
2323

@@ -27,14 +27,14 @@
2727
* @since 5.3
2828
*/
2929
@Sealed
30-
public interface ClientDeleteOptions {
30+
public interface ClientDeleteManyOptions extends BaseClientDeleteOptions {
3131
/**
3232
* Creates the default options.
3333
*
3434
* @return The default options.
3535
*/
36-
static ClientDeleteOptions clientDeleteOptions() {
37-
return new ConcreteClientDeleteOptions();
36+
static ClientDeleteManyOptions clientDeleteManyOptions() {
37+
return new ConcreteClientDeleteManyOptions();
3838
}
3939

4040
/**
@@ -43,7 +43,8 @@ static ClientDeleteOptions clientDeleteOptions() {
4343
* @param collation The collation. {@code null} represents the server default.
4444
* @return {@code this}.
4545
*/
46-
ClientDeleteOptions collation(@Nullable Collation collation);
46+
@Override
47+
ClientDeleteManyOptions collation(@Nullable Collation collation);
4748

4849
/**
4950
* Sets the index specification,
@@ -52,7 +53,8 @@ static ClientDeleteOptions clientDeleteOptions() {
5253
* @param hint The index specification. {@code null} represents the server default.
5354
* @return {@code this}.
5455
*/
55-
ClientDeleteOptions hint(@Nullable Bson hint);
56+
@Override
57+
ClientDeleteManyOptions hint(@Nullable Bson hint);
5658

5759
/**
5860
* Sets the index name,
@@ -61,5 +63,6 @@ static ClientDeleteOptions clientDeleteOptions() {
6163
* @param hintString The index name. {@code null} represents the server default.
6264
* @return {@code this}.
6365
*/
64-
ClientDeleteOptions hintString(@Nullable String hintString);
66+
@Override
67+
ClientDeleteManyOptions hintString(@Nullable String hintString);
6568
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright 2008-present MongoDB, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.mongodb.client.model.bulk;
17+
18+
import com.mongodb.annotations.Sealed;
19+
import com.mongodb.client.model.Collation;
20+
import com.mongodb.internal.client.model.bulk.ConcreteClientDeleteOneOptions;
21+
import com.mongodb.lang.Nullable;
22+
import org.bson.conversions.Bson;
23+
24+
/**
25+
* The options to apply when deleting a document.
26+
*
27+
* @since 5.3
28+
*/
29+
@Sealed
30+
public interface ClientDeleteOneOptions extends BaseClientDeleteOptions {
31+
/**
32+
* Creates the default options.
33+
*
34+
* @return The default options.
35+
*/
36+
static ClientDeleteOneOptions clientDeleteOneOptions() {
37+
return new ConcreteClientDeleteOneOptions();
38+
}
39+
40+
/**
41+
* Sets the collation.
42+
*
43+
* @param collation The collation. {@code null} represents the server default.
44+
* @return {@code this}.
45+
*/
46+
@Override
47+
ClientDeleteOneOptions collation(@Nullable Collation collation);
48+
49+
/**
50+
* Sets the index specification,
51+
* {@code null}-ifies {@linkplain #hintString(String) hint string}.
52+
*
53+
* @param hint The index specification. {@code null} represents the server default.
54+
* @return {@code this}.
55+
*/
56+
@Override
57+
ClientDeleteOneOptions hint(@Nullable Bson hint);
58+
59+
/**
60+
* Sets the index name,
61+
* {@code null}-ifies {@linkplain #hint(Bson) hint}.
62+
*
63+
* @param hintString The index name. {@code null} represents the server default.
64+
* @return {@code this}.
65+
*/
66+
@Override
67+
ClientDeleteOneOptions hintString(@Nullable String hintString);
68+
}

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ static <TDocument> ClientNamespacedInsertOneModel insertOne(final MongoNamespace
6262

6363
/**
6464
* Creates a model for updating at most one document in the {@code namespace} matching the {@code filter}.
65-
* This method is functionally equivalent to {@link #updateOne(MongoNamespace, Bson, Bson, ClientUpdateOptions)}
66-
* with the {@linkplain ClientUpdateOptions#clientUpdateOptions() default options}.
65+
* This method is functionally equivalent to {@link #updateOne(MongoNamespace, Bson, Bson, ClientUpdateOneOptions)}
66+
* with the {@linkplain ClientUpdateOneOptions#clientUpdateOneOptions() default options}.
6767
*
6868
* @param namespace The namespace.
6969
* @param filter The filter.
@@ -91,7 +91,7 @@ static ClientNamespacedUpdateOneModel updateOne(final MongoNamespace namespace,
9191
* @see Updates
9292
*/
9393
static ClientNamespacedUpdateOneModel updateOne(
94-
final MongoNamespace namespace, final Bson filter, final Bson update, final ClientUpdateOptions options) {
94+
final MongoNamespace namespace, final Bson filter, final Bson update, final ClientUpdateOneOptions options) {
9595
notNull("namespace", namespace);
9696
notNull("filter", filter);
9797
notNull("update", update);
@@ -101,8 +101,8 @@ static ClientNamespacedUpdateOneModel updateOne(
101101

102102
/**
103103
* Creates a model for updating at most one document in the {@code namespace} matching the {@code filter}.
104-
* This method is functionally equivalent to {@link #updateOne(MongoNamespace, Bson, Iterable, ClientUpdateOptions)}
105-
* with the {@linkplain ClientUpdateOptions#clientUpdateOptions() default options}.
104+
* This method is functionally equivalent to {@link #updateOne(MongoNamespace, Bson, Iterable, ClientUpdateOneOptions)}
105+
* with the {@linkplain ClientUpdateOneOptions#clientUpdateOneOptions() default options}.
106106
*
107107
* @param namespace The namespace.
108108
* @param filter The filter.
@@ -131,7 +131,7 @@ static ClientNamespacedUpdateOneModel updateOne(
131131
* @see Aggregates
132132
*/
133133
static ClientNamespacedUpdateOneModel updateOne(
134-
final MongoNamespace namespace, final Bson filter, final Iterable<? extends Bson> updatePipeline, final ClientUpdateOptions options) {
134+
final MongoNamespace namespace, final Bson filter, final Iterable<? extends Bson> updatePipeline, final ClientUpdateOneOptions options) {
135135
notNull("namespace", namespace);
136136
notNull("filter", filter);
137137
notNull("updatePipeline", updatePipeline);
@@ -141,8 +141,8 @@ static ClientNamespacedUpdateOneModel updateOne(
141141

142142
/**
143143
* Creates a model for updating all documents in the {@code namespace} matching the {@code filter}.
144-
* This method is functionally equivalent to {@link #updateMany(MongoNamespace, Bson, Bson, ClientUpdateOptions)}
145-
* with the {@linkplain ClientUpdateOptions#clientUpdateOptions() default}.
144+
* This method is functionally equivalent to {@link #updateMany(MongoNamespace, Bson, Bson, ClientUpdateManyOptions)}
145+
* with the {@linkplain ClientUpdateManyOptions#clientUpdateManyOptions() default}.
146146
*
147147
* @param namespace The namespace.
148148
* @param filter The filter.
@@ -170,7 +170,7 @@ static ClientNamespacedUpdateManyModel updateMany(final MongoNamespace namespace
170170
* @see Updates
171171
*/
172172
static ClientNamespacedUpdateManyModel updateMany(
173-
final MongoNamespace namespace, final Bson filter, final Bson update, final ClientUpdateOptions options) {
173+
final MongoNamespace namespace, final Bson filter, final Bson update, final ClientUpdateManyOptions options) {
174174
notNull("namespace", namespace);
175175
notNull("filter", filter);
176176
notNull("update", update);
@@ -180,8 +180,8 @@ static ClientNamespacedUpdateManyModel updateMany(
180180

181181
/**
182182
* Creates a model for updating all documents in the {@code namespace} matching the {@code filter}.
183-
* This method is functionally equivalent to {@link #updateMany(MongoNamespace, Bson, Iterable, ClientUpdateOptions)}
184-
* with the {@linkplain ClientUpdateOptions#clientUpdateOptions() default options}.
183+
* This method is functionally equivalent to {@link #updateMany(MongoNamespace, Bson, Iterable, ClientUpdateManyOptions)}
184+
* with the {@linkplain ClientUpdateManyOptions#clientUpdateManyOptions() default options}.
185185
*
186186
* @param namespace The namespace.
187187
* @param filter The filter.
@@ -210,7 +210,7 @@ static ClientNamespacedUpdateManyModel updateMany(
210210
* @see Aggregates
211211
*/
212212
static ClientNamespacedUpdateManyModel updateMany(
213-
final MongoNamespace namespace, final Bson filter, final Iterable<? extends Bson> updatePipeline, final ClientUpdateOptions options) {
213+
final MongoNamespace namespace, final Bson filter, final Iterable<? extends Bson> updatePipeline, final ClientUpdateManyOptions options) {
214214
notNull("namespace", namespace);
215215
notNull("filter", filter);
216216
notNull("updatePipeline", updatePipeline);
@@ -220,8 +220,8 @@ static ClientNamespacedUpdateManyModel updateMany(
220220

221221
/**
222222
* Creates a model for replacing at most one document in the {@code namespace} matching the {@code filter}.
223-
* This method is functionally equivalent to {@link #replaceOne(MongoNamespace, Bson, Object, ClientReplaceOptions)}
224-
* with the {@linkplain ClientReplaceOptions#clientReplaceOptions() default options}.
223+
* This method is functionally equivalent to {@link #replaceOne(MongoNamespace, Bson, Object, ClientReplaceOneOptions)}
224+
* with the {@linkplain ClientReplaceOneOptions#clientReplaceOneOptions() default options}.
225225
*
226226
* @param namespace The namespace.
227227
* @param filter The filter.
@@ -251,7 +251,7 @@ static <TDocument> ClientNamespacedReplaceOneModel replaceOne(final MongoNamespa
251251
* @see Filters
252252
*/
253253
static <TDocument> ClientNamespacedReplaceOneModel replaceOne(
254-
final MongoNamespace namespace, final Bson filter, final TDocument replacement, final ClientReplaceOptions options) {
254+
final MongoNamespace namespace, final Bson filter, final TDocument replacement, final ClientReplaceOneOptions options) {
255255
notNull("namespace", namespace);
256256
notNull("filter", filter);
257257
notNull("replacement", replacement);
@@ -261,8 +261,8 @@ static <TDocument> ClientNamespacedReplaceOneModel replaceOne(
261261

262262
/**
263263
* Creates a model for deleting at most one document from the {@code namespace} matching the {@code filter}.
264-
* This method is functionally equivalent to {@link #deleteOne(MongoNamespace, Bson, ClientDeleteOptions)}
265-
* with the {@linkplain ClientDeleteOptions#clientDeleteOptions() default options}.
264+
* This method is functionally equivalent to {@link #deleteOne(MongoNamespace, Bson, ClientDeleteOneOptions)}
265+
* with the {@linkplain ClientDeleteOneOptions#clientDeleteOneOptions() default options}.
266266
*
267267
* @param namespace The namespace.
268268
* @param filter The filter.
@@ -284,7 +284,7 @@ static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace,
284284
* @return The requested {@link ClientNamespacedDeleteOneModel}.
285285
* @see Filters
286286
*/
287-
static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace, final Bson filter, final ClientDeleteOptions options) {
287+
static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace, final Bson filter, final ClientDeleteOneOptions options) {
288288
notNull("namespace", namespace);
289289
notNull("filter", filter);
290290
notNull("options", options);
@@ -293,8 +293,8 @@ static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace,
293293

294294
/**
295295
* Creates a model for deleting all documents from the {@code namespace} matching the {@code filter}.
296-
* This method is functionally equivalent to {@link #deleteMany(MongoNamespace, Bson, ClientDeleteOptions)}
297-
* with the {@linkplain ClientDeleteOptions#clientDeleteOptions() default options}.
296+
* This method is functionally equivalent to {@link #deleteMany(MongoNamespace, Bson, ClientDeleteManyOptions)}
297+
* with the {@linkplain ClientDeleteManyOptions#clientDeleteManyOptions() default options}.
298298
*
299299
* @param namespace The namespace.
300300
* @param filter The filter.
@@ -316,7 +316,7 @@ static ClientNamespacedDeleteManyModel deleteMany(final MongoNamespace namespace
316316
* @return The requested {@link ClientNamespacedDeleteManyModel}.
317317
* @see Filters
318318
*/
319-
static ClientNamespacedDeleteManyModel deleteMany(final MongoNamespace namespace, final Bson filter, final ClientDeleteOptions options) {
319+
static ClientNamespacedDeleteManyModel deleteMany(final MongoNamespace namespace, final Bson filter, final ClientDeleteManyOptions options) {
320320
notNull("namespace", namespace);
321321
notNull("filter", filter);
322322
notNull("options", options);

0 commit comments

Comments
 (0)