Skip to content

Commit d75865c

Browse files
authored
Add more Base* interfaces to better reflect the methods shared by different client write model options (#1597)
JAVA-4586
1 parent 6c4883b commit d75865c

8 files changed

+120
-23
lines changed

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

+1-11
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,8 @@
1616

1717
package com.mongodb.client.model.bulk;
1818

19-
import com.mongodb.client.model.Collation;
20-
import com.mongodb.lang.Nullable;
21-
import org.bson.conversions.Bson;
22-
2319
/**
2420
* The methods declared in this interface are part of the public API of subclasses or sub-interfaces.
2521
*/
26-
interface BaseClientDeleteOptions {
27-
28-
BaseClientDeleteOptions collation(@Nullable Collation collation);
29-
30-
BaseClientDeleteOptions hint(@Nullable Bson hint);
31-
32-
BaseClientDeleteOptions hintString(@Nullable String hintString);
22+
interface BaseClientDeleteOptions extends BaseClientWriteModelOptions {
3323
}

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

+1-10
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,13 @@
1515
*/
1616
package com.mongodb.client.model.bulk;
1717

18-
import com.mongodb.client.model.Collation;
1918
import com.mongodb.lang.Nullable;
2019
import org.bson.conversions.Bson;
2120

2221
/**
2322
* The methods declared in this interface are part of the public API of subclasses or sub-interfaces.
2423
*/
25-
interface BaseClientUpdateOptions {
24+
interface BaseClientUpdateOptions extends BaseClientWriteModelOptions, BaseClientUpsertableWriteModelOptions {
2625

2726
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);
3627
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.lang.Nullable;
20+
21+
/**
22+
* The methods declared in this interface are part of the public API of subclasses or sub-interfaces.
23+
*/
24+
interface BaseClientUpsertableWriteModelOptions {
25+
BaseClientUpsertableWriteModelOptions upsert(@Nullable Boolean upsert);
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 BaseClientWriteModelOptions {
27+
BaseClientWriteModelOptions collation(@Nullable Collation collation);
28+
29+
BaseClientWriteModelOptions hint(@Nullable Bson hint);
30+
31+
BaseClientWriteModelOptions hintString(@Nullable String hintString);
32+
}

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
* @since 5.3
2828
*/
2929
@Sealed
30-
public interface ClientReplaceOneOptions {
30+
public interface ClientReplaceOneOptions extends BaseClientWriteModelOptions, BaseClientUpsertableWriteModelOptions {
3131
/**
3232
* Creates the default options.
3333
*
@@ -43,6 +43,7 @@ static ClientReplaceOneOptions clientReplaceOneOptions() {
4343
* @param collation The collation. {@code null} represents the server default.
4444
* @return {@code this}.
4545
*/
46+
@Override
4647
ClientReplaceOneOptions collation(@Nullable Collation collation);
4748

4849
/**
@@ -52,6 +53,7 @@ static ClientReplaceOneOptions clientReplaceOneOptions() {
5253
* @param hint The index specification. {@code null} represents the server default.
5354
* @return {@code this}.
5455
*/
56+
@Override
5557
ClientReplaceOneOptions hint(@Nullable Bson hint);
5658

5759
/**
@@ -61,6 +63,7 @@ static ClientReplaceOneOptions clientReplaceOneOptions() {
6163
* @param hintString The index name. {@code null} represents the server default.
6264
* @return {@code this}.
6365
*/
66+
@Override
6467
ClientReplaceOneOptions hintString(@Nullable String hintString);
6568

6669
/**
@@ -69,5 +72,6 @@ static ClientReplaceOneOptions clientReplaceOneOptions() {
6972
* @param upsert The upsert flag. {@code null} represents the server default.
7073
* @return {@code this}.
7174
*/
75+
@Override
7276
ClientReplaceOneOptions upsert(@Nullable Boolean upsert);
7377
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* @since 5.3
2929
*/
3030
@Sealed
31-
public interface ClientUpdateOneOptions extends BaseClientUpdateOptions{
31+
public interface ClientUpdateOneOptions extends BaseClientUpdateOptions {
3232
/**
3333
* Creates the default options.
3434
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.MongoBaseInterfaceAssertions;
20+
import org.junit.jupiter.api.Test;
21+
22+
final class BaseClientUpsertableWriteModelOptionsTest {
23+
@Test
24+
void testAllSubInterfacesOverrideMethods() {
25+
MongoBaseInterfaceAssertions.assertSubtypeReturn(BaseClientUpsertableWriteModelOptions.class);
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.MongoBaseInterfaceAssertions;
20+
import org.junit.jupiter.api.Test;
21+
22+
final class BaseClientWriteModelOptionsTest {
23+
@Test
24+
void testAllSubInterfacesOverrideMethods() {
25+
MongoBaseInterfaceAssertions.assertSubtypeReturn(BaseClientWriteModelOptions.class);
26+
}
27+
}

0 commit comments

Comments
 (0)