Skip to content

Commit 6f01e61

Browse files
committed
Replace ConcreteClientNamespacedWriteModel with multiple more specific concrete types
JAVA-5527
1 parent 301a2ba commit 6f01e61

8 files changed

+194
-36
lines changed

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

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
import com.mongodb.internal.client.model.bulk.ConcreteClientDeleteManyModel;
2525
import com.mongodb.internal.client.model.bulk.ConcreteClientDeleteOneModel;
2626
import com.mongodb.internal.client.model.bulk.ConcreteClientInsertOneModel;
27-
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedWriteModel;
27+
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedDeleteManyModel;
28+
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedDeleteOneModel;
29+
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedInsertOneModel;
30+
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedReplaceOneModel;
31+
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedUpdateManyModel;
32+
import com.mongodb.internal.client.model.bulk.ConcreteClientNamespacedUpdateOneModel;
2833
import com.mongodb.internal.client.model.bulk.ConcreteClientReplaceOneModel;
2934
import com.mongodb.internal.client.model.bulk.ConcreteClientUpdateManyModel;
3035
import com.mongodb.internal.client.model.bulk.ConcreteClientUpdateOneModel;
@@ -53,7 +58,7 @@ public interface ClientNamespacedWriteModel {
5358
static <TDocument> ClientNamespacedInsertOneModel insertOne(final MongoNamespace namespace, final TDocument document) {
5459
notNull("namespace", namespace);
5560
notNull("document", document);
56-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientInsertOneModel(document));
61+
return new ConcreteClientNamespacedInsertOneModel(namespace, new ConcreteClientInsertOneModel(document));
5762
}
5863

5964
/**
@@ -72,7 +77,7 @@ static ClientNamespacedUpdateOneModel updateOne(final MongoNamespace namespace,
7277
notNull("namespace", namespace);
7378
notNull("filter", filter);
7479
notNull("update", update);
75-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateOneModel(filter, update, null, null));
80+
return new ConcreteClientNamespacedUpdateOneModel(namespace, new ConcreteClientUpdateOneModel(filter, update, null, null));
7681
}
7782

7883
/**
@@ -92,7 +97,7 @@ static ClientNamespacedUpdateOneModel updateOne(
9297
notNull("filter", filter);
9398
notNull("update", update);
9499
notNull("options", options);
95-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateOneModel(filter, update, null, options));
100+
return new ConcreteClientNamespacedUpdateOneModel(namespace, new ConcreteClientUpdateOneModel(filter, update, null, options));
96101
}
97102

98103
/**
@@ -112,7 +117,7 @@ static ClientNamespacedUpdateOneModel updateOne(
112117
notNull("namespace", namespace);
113118
notNull("filter", filter);
114119
notNull("updatePipeline", updatePipeline);
115-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateOneModel(filter, null, updatePipeline, null));
120+
return new ConcreteClientNamespacedUpdateOneModel(namespace, new ConcreteClientUpdateOneModel(filter, null, updatePipeline, null));
116121
}
117122

118123
/**
@@ -132,7 +137,7 @@ static ClientNamespacedUpdateOneModel updateOne(
132137
notNull("filter", filter);
133138
notNull("updatePipeline", updatePipeline);
134139
notNull("options", options);
135-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateOneModel(filter, null, updatePipeline, options));
140+
return new ConcreteClientNamespacedUpdateOneModel(namespace, new ConcreteClientUpdateOneModel(filter, null, updatePipeline, options));
136141
}
137142

138143
/**
@@ -151,7 +156,7 @@ static ClientNamespacedUpdateManyModel updateMany(final MongoNamespace namespace
151156
notNull("namespace", namespace);
152157
notNull("filter", filter);
153158
notNull("update", update);
154-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateManyModel(filter, update, null, null));
159+
return new ConcreteClientNamespacedUpdateManyModel(namespace, new ConcreteClientUpdateManyModel(filter, update, null, null));
155160
}
156161

157162
/**
@@ -171,7 +176,7 @@ static ClientNamespacedUpdateManyModel updateMany(
171176
notNull("filter", filter);
172177
notNull("update", update);
173178
notNull("options", options);
174-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateManyModel(filter, update, null, options));
179+
return new ConcreteClientNamespacedUpdateManyModel(namespace, new ConcreteClientUpdateManyModel(filter, update, null, options));
175180
}
176181

177182
/**
@@ -191,7 +196,7 @@ static ClientNamespacedUpdateManyModel updateMany(
191196
notNull("namespace", namespace);
192197
notNull("filter", filter);
193198
notNull("updatePipeline", updatePipeline);
194-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateManyModel(filter, null, updatePipeline, null));
199+
return new ConcreteClientNamespacedUpdateManyModel(namespace, new ConcreteClientUpdateManyModel(filter, null, updatePipeline, null));
195200
}
196201

197202
/**
@@ -211,7 +216,7 @@ static ClientNamespacedUpdateManyModel updateMany(
211216
notNull("filter", filter);
212217
notNull("updatePipeline", updatePipeline);
213218
notNull("options", options);
214-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientUpdateManyModel(filter, null, updatePipeline, options));
219+
return new ConcreteClientNamespacedUpdateManyModel(namespace, new ConcreteClientUpdateManyModel(filter, null, updatePipeline, options));
215220
}
216221

217222
/**
@@ -231,7 +236,7 @@ static <TDocument> ClientNamespacedReplaceOneModel replaceOne(final MongoNamespa
231236
notNull("namespace", namespace);
232237
notNull("filter", filter);
233238
notNull("replacement", replacement);
234-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientReplaceOneModel(filter, replacement, null));
239+
return new ConcreteClientNamespacedReplaceOneModel(namespace, new ConcreteClientReplaceOneModel(filter, replacement, null));
235240
}
236241

237242
/**
@@ -252,7 +257,7 @@ static <TDocument> ClientNamespacedReplaceOneModel replaceOne(
252257
notNull("filter", filter);
253258
notNull("replacement", replacement);
254259
notNull("options", options);
255-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientReplaceOneModel(filter, replacement, options));
260+
return new ConcreteClientNamespacedReplaceOneModel(namespace, new ConcreteClientReplaceOneModel(filter, replacement, options));
256261
}
257262

258263
/**
@@ -268,7 +273,7 @@ static <TDocument> ClientNamespacedReplaceOneModel replaceOne(
268273
static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace, final Bson filter) {
269274
notNull("namespace", namespace);
270275
notNull("filter", filter);
271-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientDeleteOneModel(filter, null));
276+
return new ConcreteClientNamespacedDeleteOneModel(namespace, new ConcreteClientDeleteOneModel(filter, null));
272277
}
273278

274279
/**
@@ -284,7 +289,7 @@ static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace,
284289
notNull("namespace", namespace);
285290
notNull("filter", filter);
286291
notNull("options", options);
287-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientDeleteOneModel(filter, options));
292+
return new ConcreteClientNamespacedDeleteOneModel(namespace, new ConcreteClientDeleteOneModel(filter, options));
288293
}
289294

290295
/**
@@ -300,7 +305,7 @@ static ClientNamespacedDeleteOneModel deleteOne(final MongoNamespace namespace,
300305
static ClientNamespacedDeleteManyModel deleteMany(final MongoNamespace namespace, final Bson filter) {
301306
notNull("namespace", namespace);
302307
notNull("filter", filter);
303-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientDeleteManyModel(filter, null));
308+
return new ConcreteClientNamespacedDeleteManyModel(namespace, new ConcreteClientDeleteManyModel(filter, null));
304309
}
305310

306311
/**
@@ -316,6 +321,6 @@ static ClientNamespacedDeleteManyModel deleteMany(final MongoNamespace namespace
316321
notNull("namespace", namespace);
317322
notNull("filter", filter);
318323
notNull("options", options);
319-
return new ConcreteClientNamespacedWriteModel(namespace, new ConcreteClientDeleteManyModel(filter, options));
324+
return new ConcreteClientNamespacedDeleteManyModel(namespace, new ConcreteClientDeleteManyModel(filter, options));
320325
}
321326
}

driver-core/src/main/com/mongodb/internal/client/model/bulk/ConcreteClientNamespacedWriteModel.java renamed to driver-core/src/main/com/mongodb/internal/client/model/bulk/AbstractClientNamespacedWriteModel.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,26 @@
1717
package com.mongodb.internal.client.model.bulk;
1818

1919
import com.mongodb.MongoNamespace;
20-
import com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel;
21-
import com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel;
22-
import com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel;
23-
import com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel;
24-
import com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel;
25-
import com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel;
2620

27-
/**
28-
* This class is not part of the public API and may be removed or changed at any time.
29-
*/
30-
public final class ConcreteClientNamespacedWriteModel
31-
implements ClientNamespacedInsertOneModel,
32-
ClientNamespacedUpdateOneModel,
33-
ClientNamespacedUpdateManyModel,
34-
ClientNamespacedReplaceOneModel,
35-
ClientNamespacedDeleteOneModel,
36-
ClientNamespacedDeleteManyModel {
21+
abstract class AbstractClientNamespacedWriteModel {
3722
private final MongoNamespace namespace;
3823
private final ClientWriteModel model;
3924

40-
public ConcreteClientNamespacedWriteModel(final MongoNamespace namespace, final ClientWriteModel model) {
25+
AbstractClientNamespacedWriteModel(final MongoNamespace namespace, final ClientWriteModel model) {
4126
this.namespace = namespace;
4227
this.model = model;
4328
}
4429

45-
public MongoNamespace getNamespace() {
30+
public final MongoNamespace getNamespace() {
4631
return namespace;
4732
}
4833

49-
public ClientWriteModel getModel() {
34+
public final ClientWriteModel getModel() {
5035
return model;
5136
}
5237

5338
@Override
54-
public String toString() {
39+
public final String toString() {
5540
return "ClientNamespacedWriteModel{"
5641
+ "namespace=" + namespace
5742
+ ", model=" + model
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.internal.client.model.bulk;
17+
18+
import com.mongodb.MongoNamespace;
19+
import com.mongodb.client.model.bulk.ClientNamespacedDeleteManyModel;
20+
21+
/**
22+
* This class is not part of the public API and may be removed or changed at any time.
23+
*/
24+
public final class ConcreteClientNamespacedDeleteManyModel extends AbstractClientNamespacedWriteModel implements ClientNamespacedDeleteManyModel {
25+
public ConcreteClientNamespacedDeleteManyModel(final MongoNamespace namespace, final ClientWriteModel model) {
26+
super(namespace, model);
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.internal.client.model.bulk;
17+
18+
import com.mongodb.MongoNamespace;
19+
import com.mongodb.client.model.bulk.ClientNamespacedDeleteOneModel;
20+
21+
/**
22+
* This class is not part of the public API and may be removed or changed at any time.
23+
*/
24+
public final class ConcreteClientNamespacedDeleteOneModel extends AbstractClientNamespacedWriteModel implements ClientNamespacedDeleteOneModel {
25+
public ConcreteClientNamespacedDeleteOneModel(final MongoNamespace namespace, final ClientWriteModel model) {
26+
super(namespace, model);
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.internal.client.model.bulk;
17+
18+
import com.mongodb.MongoNamespace;
19+
import com.mongodb.client.model.bulk.ClientNamespacedInsertOneModel;
20+
21+
/**
22+
* This class is not part of the public API and may be removed or changed at any time.
23+
*/
24+
public final class ConcreteClientNamespacedInsertOneModel extends AbstractClientNamespacedWriteModel implements ClientNamespacedInsertOneModel {
25+
public ConcreteClientNamespacedInsertOneModel(final MongoNamespace namespace, final ClientWriteModel model) {
26+
super(namespace, model);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.internal.client.model.bulk;
17+
18+
import com.mongodb.MongoNamespace;
19+
import com.mongodb.client.model.bulk.ClientNamespacedReplaceOneModel;
20+
21+
/**
22+
* This class is not part of the public API and may be removed or changed at any time.
23+
*/
24+
public final class ConcreteClientNamespacedReplaceOneModel extends AbstractClientNamespacedWriteModel implements ClientNamespacedReplaceOneModel {
25+
public ConcreteClientNamespacedReplaceOneModel(final MongoNamespace namespace, final ClientWriteModel model) {
26+
super(namespace, model);
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.internal.client.model.bulk;
17+
18+
import com.mongodb.MongoNamespace;
19+
import com.mongodb.client.model.bulk.ClientNamespacedUpdateManyModel;
20+
21+
/**
22+
* This class is not part of the public API and may be removed or changed at any time.
23+
*/
24+
public final class ConcreteClientNamespacedUpdateManyModel extends AbstractClientNamespacedWriteModel implements ClientNamespacedUpdateManyModel {
25+
public ConcreteClientNamespacedUpdateManyModel(final MongoNamespace namespace, final ClientWriteModel model) {
26+
super(namespace, model);
27+
}
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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.internal.client.model.bulk;
17+
18+
import com.mongodb.MongoNamespace;
19+
import com.mongodb.client.model.bulk.ClientNamespacedUpdateOneModel;
20+
21+
/**
22+
* This class is not part of the public API and may be removed or changed at any time.
23+
*/
24+
public final class ConcreteClientNamespacedUpdateOneModel extends AbstractClientNamespacedWriteModel implements ClientNamespacedUpdateOneModel {
25+
public ConcreteClientNamespacedUpdateOneModel(final MongoNamespace namespace, final ClientWriteModel model) {
26+
super(namespace, model);
27+
}
28+
}

0 commit comments

Comments
 (0)