Skip to content

Add more Base* interfaces to better reflect the methods shared by different client write model options #1597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Bson> arrayFilters);

BaseClientUpdateOptions collation(@Nullable Collation collation);

BaseClientUpdateOptions hint(@Nullable Bson hint);

BaseClientUpdateOptions hintString(@Nullable String hintString);

BaseClientUpdateOptions upsert(@Nullable Boolean upsert);
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @since 5.3
*/
@Sealed
public interface ClientReplaceOneOptions {
public interface ClientReplaceOneOptions extends BaseClientWriteModelOptions, BaseClientUpsertableWriteModelOptions {
/**
* Creates the default options.
*
Expand All @@ -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);

/**
Expand All @@ -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);

/**
Expand All @@ -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);

/**
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @since 5.3
*/
@Sealed
public interface ClientUpdateOneOptions extends BaseClientUpdateOptions{
public interface ClientUpdateOneOptions extends BaseClientUpdateOptions {
/**
* Creates the default options.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}