30
30
import org .bson .BsonBoolean ;
31
31
import org .bson .BsonDocument ;
32
32
import org .bson .BsonString ;
33
- import org .bson .BsonValue ;
34
33
import org .bson .FieldNameValidator ;
35
34
import org .bson .codecs .Decoder ;
36
- import org .bson .conversions .Bson ;
37
35
38
- import java .util .ArrayList ;
39
36
import java .util .HashMap ;
40
37
import java .util .List ;
41
38
import java .util .Map ;
60
57
@ Deprecated
61
58
public class FindAndUpdateOperation <T > extends BaseFindAndModifyOperation <T > {
62
59
private final BsonDocument update ;
63
- private final List <? extends Bson > updatePipeline ;
60
+ private final List <BsonDocument > updatePipeline ;
64
61
private BsonDocument filter ;
65
62
private BsonDocument projection ;
66
63
private BsonDocument sort ;
@@ -129,7 +126,7 @@ public FindAndUpdateOperation(final MongoNamespace namespace, final WriteConcern
129
126
* @mongodb.server.release 4.2
130
127
*/
131
128
public FindAndUpdateOperation (final MongoNamespace namespace , final WriteConcern writeConcern , final boolean retryWrites ,
132
- final Decoder <T > decoder , final List <? extends Bson > update ) {
129
+ final Decoder <T > decoder , final List <BsonDocument > update ) {
133
130
super (namespace , writeConcern , retryWrites , decoder );
134
131
this .updatePipeline = update ;
135
132
this .update = null ;
@@ -153,7 +150,7 @@ public BsonDocument getUpdate() {
153
150
* @mongodb.server.release 4.2
154
151
*/
155
152
@ Nullable
156
- public List <? extends Bson > getUpdatePipeline () {
153
+ public List <BsonDocument > getUpdatePipeline () {
157
154
return updatePipeline ;
158
155
}
159
156
@@ -384,17 +381,6 @@ public BsonDocument create(final ServerDescription serverDescription, final Conn
384
381
};
385
382
}
386
383
387
- private List <BsonValue > toBsonValueList (final List <? extends Bson > bsonList ) {
388
- if (bsonList == null ) {
389
- return null ;
390
- }
391
- List <BsonValue > bsonValueList = new ArrayList <BsonValue >(bsonList .size ());
392
- for (Object cur : bsonList ) {
393
- bsonValueList .add ((BsonValue ) cur );
394
- }
395
- return bsonValueList ;
396
- }
397
-
398
384
private BsonDocument createCommand (final SessionContext sessionContext , final ServerDescription serverDescription ,
399
385
final ConnectionDescription connectionDescription ) {
400
386
validateCollation (connectionDescription , collation );
@@ -406,7 +392,7 @@ private BsonDocument createCommand(final SessionContext sessionContext, final Se
406
392
putIfTrue (commandDocument , "upsert" , isUpsert ());
407
393
putIfNotZero (commandDocument , "maxTimeMS" , getMaxTime (MILLISECONDS ));
408
394
if (getUpdatePipeline () != null ) {
409
- commandDocument .put ("update" , new BsonArray (toBsonValueList ( getUpdatePipeline () )));
395
+ commandDocument .put ("update" , new BsonArray (getUpdatePipeline ()));
410
396
} else {
411
397
putIfNotNull (commandDocument , "update" , getUpdate ());
412
398
}
0 commit comments