3030import org .bson .BsonBoolean ;
3131import org .bson .BsonDocument ;
3232import org .bson .BsonString ;
33- import org .bson .BsonValue ;
3433import org .bson .FieldNameValidator ;
3534import org .bson .codecs .Decoder ;
36- import org .bson .conversions .Bson ;
3735
38- import java .util .ArrayList ;
3936import java .util .HashMap ;
4037import java .util .List ;
4138import java .util .Map ;
6057@ Deprecated
6158public class FindAndUpdateOperation <T > extends BaseFindAndModifyOperation <T > {
6259 private final BsonDocument update ;
63- private final List <? extends Bson > updatePipeline ;
60+ private final List <BsonDocument > updatePipeline ;
6461 private BsonDocument filter ;
6562 private BsonDocument projection ;
6663 private BsonDocument sort ;
@@ -129,7 +126,7 @@ public FindAndUpdateOperation(final MongoNamespace namespace, final WriteConcern
129126 * @mongodb.server.release 4.2
130127 */
131128 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 ) {
133130 super (namespace , writeConcern , retryWrites , decoder );
134131 this .updatePipeline = update ;
135132 this .update = null ;
@@ -153,7 +150,7 @@ public BsonDocument getUpdate() {
153150 * @mongodb.server.release 4.2
154151 */
155152 @ Nullable
156- public List <? extends Bson > getUpdatePipeline () {
153+ public List <BsonDocument > getUpdatePipeline () {
157154 return updatePipeline ;
158155 }
159156
@@ -384,17 +381,6 @@ public BsonDocument create(final ServerDescription serverDescription, final Conn
384381 };
385382 }
386383
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-
398384 private BsonDocument createCommand (final SessionContext sessionContext , final ServerDescription serverDescription ,
399385 final ConnectionDescription connectionDescription ) {
400386 validateCollation (connectionDescription , collation );
@@ -406,7 +392,7 @@ private BsonDocument createCommand(final SessionContext sessionContext, final Se
406392 putIfTrue (commandDocument , "upsert" , isUpsert ());
407393 putIfNotZero (commandDocument , "maxTimeMS" , getMaxTime (MILLISECONDS ));
408394 if (getUpdatePipeline () != null ) {
409- commandDocument .put ("update" , new BsonArray (toBsonValueList ( getUpdatePipeline () )));
395+ commandDocument .put ("update" , new BsonArray (getUpdatePipeline ()));
410396 } else {
411397 putIfNotNull (commandDocument , "update" , getUpdate ());
412398 }
0 commit comments