public class RenameCollectionOperation extends Object implements AsyncWriteOperation<Void>, WriteOperation<Void>
If the new name is the same as an existing collection and dropTarget is true, this existing collection will be dropped. If dropTarget is false and the newCollectionName is the same as an existing collection, a MongoServerException will be thrown.
Constructor and Description |
---|
RenameCollectionOperation(MongoNamespace originalNamespace,
MongoNamespace newNamespace)
Deprecated.
|
RenameCollectionOperation(MongoNamespace originalNamespace,
MongoNamespace newNamespace,
WriteConcern writeConcern) |
Modifier and Type | Method and Description |
---|---|
RenameCollectionOperation |
dropTarget(boolean dropTarget)
Sets if mongod should drop the target of renameCollection prior to renaming the collection.
|
Void |
execute(WriteBinding binding)
Rename the collection with
oldCollectionName in database databaseName to the newCollectionName . |
void |
executeAsync(AsyncWriteBinding binding,
SingleResultCallback<Void> callback)
General execute which can return anything of type T
|
WriteConcern |
getWriteConcern()
Gets the write concern.
|
boolean |
isDropTarget()
Gets if mongod should drop the target of renameCollection prior to renaming the collection.
|
@Deprecated public RenameCollectionOperation(MongoNamespace originalNamespace, MongoNamespace newNamespace)
RenameCollectionOperation(MongoNamespace, MongoNamespace, WriteConcern)
originalNamespace
- the name of the collection to renamenewNamespace
- the desired new name for the collectionpublic RenameCollectionOperation(MongoNamespace originalNamespace, MongoNamespace newNamespace, WriteConcern writeConcern)
originalNamespace
- the name of the collection to renamenewNamespace
- the desired new name for the collectionwriteConcern
- the writeConcernpublic WriteConcern getWriteConcern()
public boolean isDropTarget()
public RenameCollectionOperation dropTarget(boolean dropTarget)
dropTarget
- true if mongod should drop the target of renameCollection prior to renaming the collection.public Void execute(WriteBinding binding)
oldCollectionName
in database databaseName
to the newCollectionName
.execute
in interface WriteOperation<Void>
binding
- the bindingMongoServerException
- if you provide a newCollectionName that is the name of an existing collection and dropTarget
is false, or if the oldCollectionName is the name of a collection that doesn't existpublic void executeAsync(AsyncWriteBinding binding, SingleResultCallback<Void> callback)
AsyncWriteOperation
executeAsync
in interface AsyncWriteOperation<Void>
binding
- the binding to execute in the context ofcallback
- the callback to be called when the operation has been executed