diff --git a/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientDeleteOptions.java b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientDeleteOptions.java index 025865a7217..8c0a74406ef 100644 --- a/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientDeleteOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientDeleteOptions.java @@ -16,18 +16,8 @@ package com.mongodb.client.model.bulk; -import com.mongodb.client.model.Collation; -import com.mongodb.lang.Nullable; -import org.bson.conversions.Bson; - /** * The methods declared in this interface are part of the public API of subclasses or sub-interfaces. */ -interface BaseClientDeleteOptions { - - BaseClientDeleteOptions collation(@Nullable Collation collation); - - BaseClientDeleteOptions hint(@Nullable Bson hint); - - BaseClientDeleteOptions hintString(@Nullable String hintString); +interface BaseClientDeleteOptions extends BaseClientWriteModelOptions { } diff --git a/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpdateOptions.java b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpdateOptions.java index 13ce34ee8bc..10b97e2f570 100644 --- a/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpdateOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpdateOptions.java @@ -15,22 +15,13 @@ */ package com.mongodb.client.model.bulk; -import com.mongodb.client.model.Collation; import com.mongodb.lang.Nullable; import org.bson.conversions.Bson; /** * The methods declared in this interface are part of the public API of subclasses or sub-interfaces. */ -interface BaseClientUpdateOptions { +interface BaseClientUpdateOptions extends BaseClientWriteModelOptions, BaseClientUpsertableWriteModelOptions { BaseClientUpdateOptions arrayFilters(@Nullable Iterable arrayFilters); - - BaseClientUpdateOptions collation(@Nullable Collation collation); - - BaseClientUpdateOptions hint(@Nullable Bson hint); - - BaseClientUpdateOptions hintString(@Nullable String hintString); - - BaseClientUpdateOptions upsert(@Nullable Boolean upsert); } diff --git a/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpsertableWriteModelOptions.java b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpsertableWriteModelOptions.java new file mode 100644 index 00000000000..d26a96e1ba5 --- /dev/null +++ b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientUpsertableWriteModelOptions.java @@ -0,0 +1,26 @@ +/* + * Copyright 2008-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mongodb.client.model.bulk; + +import com.mongodb.lang.Nullable; + +/** + * The methods declared in this interface are part of the public API of subclasses or sub-interfaces. + */ +interface BaseClientUpsertableWriteModelOptions { + BaseClientUpsertableWriteModelOptions upsert(@Nullable Boolean upsert); +} diff --git a/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientWriteModelOptions.java b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientWriteModelOptions.java new file mode 100644 index 00000000000..f7cd4e7a491 --- /dev/null +++ b/driver-core/src/main/com/mongodb/client/model/bulk/BaseClientWriteModelOptions.java @@ -0,0 +1,32 @@ +/* + * Copyright 2008-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mongodb.client.model.bulk; + +import com.mongodb.client.model.Collation; +import com.mongodb.lang.Nullable; +import org.bson.conversions.Bson; + +/** + * The methods declared in this interface are part of the public API of subclasses or sub-interfaces. + */ +interface BaseClientWriteModelOptions { + BaseClientWriteModelOptions collation(@Nullable Collation collation); + + BaseClientWriteModelOptions hint(@Nullable Bson hint); + + BaseClientWriteModelOptions hintString(@Nullable String hintString); +} diff --git a/driver-core/src/main/com/mongodb/client/model/bulk/ClientReplaceOneOptions.java b/driver-core/src/main/com/mongodb/client/model/bulk/ClientReplaceOneOptions.java index 4aa08ae81e1..2142d736f60 100644 --- a/driver-core/src/main/com/mongodb/client/model/bulk/ClientReplaceOneOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/bulk/ClientReplaceOneOptions.java @@ -27,7 +27,7 @@ * @since 5.3 */ @Sealed -public interface ClientReplaceOneOptions { +public interface ClientReplaceOneOptions extends BaseClientWriteModelOptions, BaseClientUpsertableWriteModelOptions { /** * Creates the default options. * @@ -43,6 +43,7 @@ static ClientReplaceOneOptions clientReplaceOneOptions() { * @param collation The collation. {@code null} represents the server default. * @return {@code this}. */ + @Override ClientReplaceOneOptions collation(@Nullable Collation collation); /** @@ -52,6 +53,7 @@ static ClientReplaceOneOptions clientReplaceOneOptions() { * @param hint The index specification. {@code null} represents the server default. * @return {@code this}. */ + @Override ClientReplaceOneOptions hint(@Nullable Bson hint); /** @@ -61,6 +63,7 @@ static ClientReplaceOneOptions clientReplaceOneOptions() { * @param hintString The index name. {@code null} represents the server default. * @return {@code this}. */ + @Override ClientReplaceOneOptions hintString(@Nullable String hintString); /** @@ -69,5 +72,6 @@ static ClientReplaceOneOptions clientReplaceOneOptions() { * @param upsert The upsert flag. {@code null} represents the server default. * @return {@code this}. */ + @Override ClientReplaceOneOptions upsert(@Nullable Boolean upsert); } diff --git a/driver-core/src/main/com/mongodb/client/model/bulk/ClientUpdateOneOptions.java b/driver-core/src/main/com/mongodb/client/model/bulk/ClientUpdateOneOptions.java index a0e85e065e9..9b04ec6ef15 100644 --- a/driver-core/src/main/com/mongodb/client/model/bulk/ClientUpdateOneOptions.java +++ b/driver-core/src/main/com/mongodb/client/model/bulk/ClientUpdateOneOptions.java @@ -28,7 +28,7 @@ * @since 5.3 */ @Sealed -public interface ClientUpdateOneOptions extends BaseClientUpdateOptions{ +public interface ClientUpdateOneOptions extends BaseClientUpdateOptions { /** * Creates the default options. * diff --git a/driver-core/src/test/unit/com/mongodb/client/model/bulk/BaseClientUpsertableWriteModelOptionsTest.java b/driver-core/src/test/unit/com/mongodb/client/model/bulk/BaseClientUpsertableWriteModelOptionsTest.java new file mode 100644 index 00000000000..5992a508574 --- /dev/null +++ b/driver-core/src/test/unit/com/mongodb/client/model/bulk/BaseClientUpsertableWriteModelOptionsTest.java @@ -0,0 +1,27 @@ +/* + * Copyright 2008-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mongodb.client.model.bulk; + +import com.mongodb.MongoBaseInterfaceAssertions; +import org.junit.jupiter.api.Test; + +final class BaseClientUpsertableWriteModelOptionsTest { + @Test + void testAllSubInterfacesOverrideMethods() { + MongoBaseInterfaceAssertions.assertSubtypeReturn(BaseClientUpsertableWriteModelOptions.class); + } +} diff --git a/driver-core/src/test/unit/com/mongodb/client/model/bulk/BaseClientWriteModelOptionsTest.java b/driver-core/src/test/unit/com/mongodb/client/model/bulk/BaseClientWriteModelOptionsTest.java new file mode 100644 index 00000000000..66fec81632e --- /dev/null +++ b/driver-core/src/test/unit/com/mongodb/client/model/bulk/BaseClientWriteModelOptionsTest.java @@ -0,0 +1,27 @@ +/* + * Copyright 2008-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.mongodb.client.model.bulk; + +import com.mongodb.MongoBaseInterfaceAssertions; +import org.junit.jupiter.api.Test; + +final class BaseClientWriteModelOptionsTest { + @Test + void testAllSubInterfacesOverrideMethods() { + MongoBaseInterfaceAssertions.assertSubtypeReturn(BaseClientWriteModelOptions.class); + } +}