Skip to content

Commit 88b7cd2

Browse files
committed
Let's put options back to AbstractClientDeleteModel, AbstractClientUpdateModel
mongodb#1593
1 parent f0f7ed3 commit 88b7cd2

6 files changed

+23
-42
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,28 @@
2222
*/
2323
public abstract class AbstractClientDeleteModel<T> implements ClientWriteModel {
2424
private final Bson filter;
25+
private final T options;
2526

26-
AbstractClientDeleteModel(final Bson filter) {
27+
AbstractClientDeleteModel(final Bson filter, final T options) {
2728
this.filter = filter;
29+
this.options = options;
2830
}
2931

3032
public final Bson getFilter() {
3133
return filter;
3234
}
3335

34-
abstract String getToStringDescription();
36+
public final T getOptions() {
37+
return options;
38+
}
3539

36-
abstract T getOptions();
40+
abstract String getToStringDescription();
3741

3842
@Override
3943
public final String toString() {
4044
return getToStringDescription()
4145
+ "{filter=" + filter
42-
+ ", options=" + getOptions()
46+
+ ", options=" + options
4347
+ '}';
4448
}
4549
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ public abstract class AbstractClientUpdateModel<T> {
3232
private final Bson update;
3333
@Nullable
3434
private final Iterable<? extends Bson> updatePipeline;
35+
private final T options;
3536

3637
AbstractClientUpdateModel(
3738
final Bson filter,
3839
@Nullable
3940
final Bson update,
40-
@Nullable final Iterable<? extends Bson> updatePipeline) {
41+
@Nullable final Iterable<? extends Bson> updatePipeline,
42+
final T options) {
4143
this.filter = filter;
4244
assertTrue(update == null ^ updatePipeline == null);
4345
this.update = update;
4446
this.updatePipeline = updatePipeline;
47+
this.options = options;
4548
}
4649

4750
public final Bson getFilter() {
@@ -56,16 +59,18 @@ public final Optional<Iterable<? extends Bson>> getUpdatePipeline() {
5659
return ofNullable(updatePipeline);
5760
}
5861

59-
abstract String getToStringDescription();
62+
public final T getOptions() {
63+
return options;
64+
}
6065

61-
abstract T getOptions();
66+
abstract String getToStringDescription();
6267

6368
@Override
6469
public final String toString() {
6570
return getToStringDescription()
6671
+ "{filter=" + filter
6772
+ ", update=" + (update != null ? update : updatePipeline)
68-
+ ", options=" + getOptions()
73+
+ ", options=" + options
6974
+ '}';
7075
}
7176
}

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,8 @@
2323
* This class is not part of the public API and may be removed or changed at any time.
2424
*/
2525
public final class ConcreteClientDeleteManyModel extends AbstractClientDeleteModel<ConcreteClientDeleteManyOptions> implements ClientWriteModel {
26-
private final ConcreteClientDeleteManyOptions options;
27-
2826
public ConcreteClientDeleteManyModel(final Bson filter, @Nullable final ClientDeleteManyOptions options) {
29-
super(filter);
30-
this.options = options == null ? ConcreteClientDeleteManyOptions.MUTABLE_EMPTY : (ConcreteClientDeleteManyOptions) options;
31-
}
32-
33-
public ConcreteClientDeleteManyOptions getOptions() {
34-
return options;
27+
super(filter, options == null ? ConcreteClientDeleteManyOptions.MUTABLE_EMPTY : (ConcreteClientDeleteManyOptions) options);
3528
}
3629

3730
@Override

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,8 @@
2323
* This class is not part of the public API and may be removed or changed at any time.
2424
*/
2525
public final class ConcreteClientDeleteOneModel extends AbstractClientDeleteModel<ConcreteClientDeleteOneOptions> implements ClientWriteModel {
26-
private final ConcreteClientDeleteOneOptions options;
27-
2826
public ConcreteClientDeleteOneModel(final Bson filter, @Nullable final ClientDeleteOneOptions options) {
29-
super(filter);
30-
this.options = options == null ? ConcreteClientDeleteOneOptions.MUTABLE_EMPTY : (ConcreteClientDeleteOneOptions) options;
31-
}
32-
33-
public ConcreteClientDeleteOneOptions getOptions() {
34-
return options;
27+
super(filter, options == null ? ConcreteClientDeleteOneOptions.MUTABLE_EMPTY : (ConcreteClientDeleteOneOptions) options);
3528
}
3629

3730
@Override

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,19 @@
2323
* This class is not part of the public API and may be removed or changed at any time.
2424
*/
2525
public final class ConcreteClientUpdateManyModel extends AbstractClientUpdateModel<ConcreteClientUpdateManyOptions> implements ClientWriteModel {
26-
private final ConcreteClientUpdateManyOptions options;
27-
2826
public ConcreteClientUpdateManyModel(
2927
final Bson filter,
3028
@Nullable
3129
final Bson update,
3230
@Nullable
3331
final Iterable<? extends Bson> updatePipeline,
3432
@Nullable final ClientUpdateManyOptions options) {
35-
super(filter, update, updatePipeline);
36-
this.options = options == null ? ConcreteClientUpdateManyOptions.MUTABLE_EMPTY : (ConcreteClientUpdateManyOptions) options;
37-
}
38-
39-
public ConcreteClientUpdateManyOptions getOptions() {
40-
return options;
33+
super(filter, update, updatePipeline,
34+
options == null ? ConcreteClientUpdateManyOptions.MUTABLE_EMPTY : (ConcreteClientUpdateManyOptions) options);
4135
}
4236

4337
@Override
4438
String getToStringDescription() {
4539
return "ClientUpdateManyModel";
4640
}
47-
48-
4941
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,15 @@
2323
* This class is not part of the public API and may be removed or changed at any time.
2424
*/
2525
public final class ConcreteClientUpdateOneModel extends AbstractClientUpdateModel<ConcreteClientUpdateOneOptions> implements ClientWriteModel {
26-
private final ConcreteClientUpdateOneOptions options;
27-
2826
public ConcreteClientUpdateOneModel(
2927
final Bson filter,
3028
@Nullable
3129
final Bson update,
3230
@Nullable
3331
final Iterable<? extends Bson> updatePipeline,
3432
@Nullable final ClientUpdateOneOptions options) {
35-
super(filter, update, updatePipeline);
36-
this.options = options == null ? ConcreteClientUpdateOneOptions.MUTABLE_EMPTY : (ConcreteClientUpdateOneOptions) options;
37-
}
38-
39-
public ConcreteClientUpdateOneOptions getOptions() {
40-
return options;
33+
super(filter, update, updatePipeline,
34+
options == null ? ConcreteClientUpdateOneOptions.MUTABLE_EMPTY : (ConcreteClientUpdateOneOptions) options);
4135
}
4236

4337
@Override

0 commit comments

Comments
 (0)