Skip to content

Commit f318185

Browse files
committed
DATAMONGO-1400 - Adapt to rename of Tuple to Pair in Spring Data Commons.
Related tickets: DATACMNS-818.
1 parent 43b4962 commit f318185

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/BulkOperations.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@
1919

2020
import org.springframework.data.mongodb.core.query.Query;
2121
import org.springframework.data.mongodb.core.query.Update;
22-
import org.springframework.data.util.Tuple;
22+
import org.springframework.data.util.Pair;
2323

2424
import com.mongodb.BulkWriteResult;
2525

@@ -78,7 +78,7 @@ public enum BulkMode {
7878
* @param updates Update operations to perform.
7979
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
8080
*/
81-
BulkOperations updateOne(List<Tuple<Query, Update>> updates);
81+
BulkOperations updateOne(List<Pair<Query, Update>> updates);
8282

8383
/**
8484
* Add a single update to the bulk operation. For the update request, all matching documents are updated.
@@ -96,7 +96,7 @@ public enum BulkMode {
9696
* @return The bulk operation.
9797
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
9898
*/
99-
BulkOperations updateMulti(List<Tuple<Query, Update>> updates);
99+
BulkOperations updateMulti(List<Pair<Query, Update>> updates);
100100

101101
/**
102102
* Add a single upsert to the bulk operation. An upsert is an update if the set of matching documents is not empty,
@@ -117,7 +117,7 @@ public enum BulkMode {
117117
* @return The bulk operation.
118118
* @return the current {@link BulkOperations} instance with the update added, will never be {@literal null}.
119119
*/
120-
BulkOperations upsert(List<Tuple<Query, Update>> updates);
120+
BulkOperations upsert(List<Pair<Query, Update>> updates);
121121

122122
/**
123123
* Add a single remove operation to the bulk operation.

Diff for: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultBulkOperations.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
2222
import org.springframework.dao.support.PersistenceExceptionTranslator;
2323
import org.springframework.data.mongodb.core.query.Query;
2424
import org.springframework.data.mongodb.core.query.Update;
25-
import org.springframework.data.util.Tuple;
25+
import org.springframework.data.util.Pair;
2626
import org.springframework.util.Assert;
2727

2828
import com.mongodb.BulkWriteException;
@@ -148,19 +148,19 @@ public BulkOperations updateOne(Query query, Update update) {
148148
Assert.notNull(query, "Query must not be null!");
149149
Assert.notNull(update, "Update must not be null!");
150150

151-
return updateOne(Arrays.asList(Tuple.of(query, update)));
151+
return updateOne(Arrays.asList(Pair.of(query, update)));
152152
}
153153

154154
/*
155155
* (non-Javadoc)
156156
* @see org.springframework.data.mongodb.core.BulkOperations#updateOne(java.util.List)
157157
*/
158158
@Override
159-
public BulkOperations updateOne(List<Tuple<Query, Update>> updates) {
159+
public BulkOperations updateOne(List<Pair<Query, Update>> updates) {
160160

161161
Assert.notNull(updates, "Updates must not be null!");
162162

163-
for (Tuple<Query, Update> update : updates) {
163+
for (Pair<Query, Update> update : updates) {
164164
update(update.getFirst(), update.getSecond(), false, false);
165165
}
166166

@@ -178,19 +178,19 @@ public BulkOperations updateMulti(Query query, Update update) {
178178
Assert.notNull(query, "Query must not be null!");
179179
Assert.notNull(update, "Update must not be null!");
180180

181-
return updateMulti(Arrays.asList(Tuple.of(query, update)));
181+
return updateMulti(Arrays.asList(Pair.of(query, update)));
182182
}
183183

184184
/*
185185
* (non-Javadoc)
186186
* @see org.springframework.data.mongodb.core.BulkOperations#updateMulti(java.util.List)
187187
*/
188188
@Override
189-
public BulkOperations updateMulti(List<Tuple<Query, Update>> updates) {
189+
public BulkOperations updateMulti(List<Pair<Query, Update>> updates) {
190190

191191
Assert.notNull(updates, "Updates must not be null!");
192192

193-
for (Tuple<Query, Update> update : updates) {
193+
for (Pair<Query, Update> update : updates) {
194194
update(update.getFirst(), update.getSecond(), false, true);
195195
}
196196

@@ -211,9 +211,9 @@ public BulkOperations upsert(Query query, Update update) {
211211
* @see org.springframework.data.mongodb.core.BulkOperations#upsert(java.util.List)
212212
*/
213213
@Override
214-
public BulkOperations upsert(List<Tuple<Query, Update>> updates) {
214+
public BulkOperations upsert(List<Pair<Query, Update>> updates) {
215215

216-
for (Tuple<Query, Update> update : updates) {
216+
for (Pair<Query, Update> update : updates) {
217217
upsert(update.getFirst(), update.getSecond());
218218
}
219219

Diff for: spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DefaultBulkOperationsIntegrationTests.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@
3131
import org.springframework.data.mongodb.core.query.Criteria;
3232
import org.springframework.data.mongodb.core.query.Query;
3333
import org.springframework.data.mongodb.core.query.Update;
34-
import org.springframework.data.util.Tuple;
34+
import org.springframework.data.util.Pair;
3535
import org.springframework.test.context.ContextConfiguration;
3636
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
3737

@@ -258,7 +258,7 @@ public void mixedBulkOrdered() {
258258
public void mixedBulkOrderedWithList() {
259259

260260
List<BaseDoc> inserts = Arrays.asList(newDoc("1", "v1"), newDoc("2", "v2"), newDoc("3", "v2"));
261-
List<Tuple<Query, Update>> updates = Arrays.asList(Tuple.of(where("value", "v2"), set("value", "v3")));
261+
List<Pair<Query, Update>> updates = Arrays.asList(Pair.of(where("value", "v2"), set("value", "v3")));
262262
List<Query> removes = Arrays.asList(where("_id", "1"));
263263

264264
BulkWriteResult result = createBulkOps(BulkMode.ORDERED).insert(inserts).updateMulti(updates).remove(removes)
@@ -276,9 +276,9 @@ private void testUpdate(BulkMode mode, boolean multi, int expectedUpdates) {
276276

277277
insertSomeDocuments();
278278

279-
List<Tuple<Query, Update>> updates = new ArrayList<Tuple<Query, Update>>();
280-
updates.add(Tuple.of(where("value", "value1"), set("value", "value3")));
281-
updates.add(Tuple.of(where("value", "value2"), set("value", "value4")));
279+
List<Pair<Query, Update>> updates = new ArrayList<Pair<Query, Update>>();
280+
updates.add(Pair.of(where("value", "value1"), set("value", "value3")));
281+
updates.add(Pair.of(where("value", "value2"), set("value", "value4")));
282282

283283
int modifiedCount = multi ? bulkOps.updateMulti(updates).execute().getModifiedCount()
284284
: bulkOps.updateOne(updates).execute().getModifiedCount();

0 commit comments

Comments
 (0)