Package com.mongodb.client.model
Class MergeOptions
- java.lang.Object
 - 
- com.mongodb.client.model.MergeOptions
 
 
- 
public final class MergeOptions extends Object
Options to control the behavior of the $merge aggregation stage- Since:
 - 3.11
 - See Also:
 Aggregates.merge(String, MergeOptions),Aggregates.merge(com.mongodb.MongoNamespace, MergeOptions)- MongoDB documentation
 - $merge stage
 - Since server release
 - 4.2
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMergeOptions.WhenMatchedThe behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).static classMergeOptions.WhenNotMatchedThe behavior of $merge if a result document does not match an existing document in the out collection. 
- 
Constructor Summary
Constructors Constructor Description MergeOptions() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)List<String>getUniqueIdentifier()Gets the fields that act as a unique identifier for a document.List<Variable<?>>getVariables()Gets the variables accessible for use in the whenMatched pipelineMergeOptions.WhenMatchedgetWhenMatched()Gets the behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).List<Bson>getWhenMatchedPipeline()Gets aggregation pipeline to update the document in the collection.MergeOptions.WhenNotMatchedgetWhenNotMatched()Gets the behavior of $merge if a result document does not match an existing document in the out collection.inthashCode()StringtoString()MergeOptionsuniqueIdentifier(String uniqueIdentifier)Sets the field that act as a unique identifier for a document.MergeOptionsuniqueIdentifier(List<String> uniqueIdentifier)Sets the field that act as a unique identifier for a document.MergeOptionsvariables(List<Variable<?>> variables)Sets the variables accessible for use in the whenMatched pipeline.MergeOptionswhenMatched(MergeOptions.WhenMatched whenMatched)Sets the behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).MergeOptionswhenMatchedPipeline(List<Bson> whenMatchedPipeline)Sets aggregation pipeline to update the document in the collection.MergeOptionswhenNotMatched(MergeOptions.WhenNotMatched whenNotMatched)Sets the behavior of $merge if a result document does not match an existing document in the out collection. 
 - 
 
- 
- 
Method Detail
- 
getUniqueIdentifier
public List<String> getUniqueIdentifier()
Gets the fields that act as a unique identifier for a document. The identifier determine if a results document matches an already existing document in the output collection.- Returns:
 - the unique identifier
 
 
- 
uniqueIdentifier
public MergeOptions uniqueIdentifier(String uniqueIdentifier)
Sets the field that act as a unique identifier for a document. The identifier determine if a results document matches an already existing document in the output collection.- Parameters:
 uniqueIdentifier- the unique identifier- Returns:
 - this
 
 
- 
uniqueIdentifier
public MergeOptions uniqueIdentifier(List<String> uniqueIdentifier)
Sets the field that act as a unique identifier for a document. The identifier determine if a results document matches an already existing document in the output collection.- Parameters:
 uniqueIdentifier- the unique identifier- Returns:
 - this
 
 
- 
getWhenMatched
public MergeOptions.WhenMatched getWhenMatched()
Gets the behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).- Returns:
 - when matched
 
 
- 
whenMatched
public MergeOptions whenMatched(MergeOptions.WhenMatched whenMatched)
Sets the behavior of $merge if a result document and an existing document in the collection have the same value for the specified on field(s).- Parameters:
 whenMatched- when matched- Returns:
 - this
 
 
- 
getVariables
public List<Variable<?>> getVariables()
Gets the variables accessible for use in the whenMatched pipeline- Returns:
 - the variables
 
 
- 
variables
public MergeOptions variables(List<Variable<?>> variables)
Sets the variables accessible for use in the whenMatched pipeline.- Parameters:
 variables- the variables- Returns:
 - this
 
 
- 
getWhenMatchedPipeline
public List<Bson> getWhenMatchedPipeline()
Gets aggregation pipeline to update the document in the collection.- Returns:
 - when matched pipeline
 - See Also:
 MergeOptions.WhenMatched.PIPELINE
 
- 
whenMatchedPipeline
public MergeOptions whenMatchedPipeline(List<Bson> whenMatchedPipeline)
Sets aggregation pipeline to update the document in the collection.- Parameters:
 whenMatchedPipeline- when matched pipeline- Returns:
 - this
 - See Also:
 MergeOptions.WhenMatched.PIPELINE
 
- 
getWhenNotMatched
public MergeOptions.WhenNotMatched getWhenNotMatched()
Gets the behavior of $merge if a result document does not match an existing document in the out collection.- Returns:
 - when not matched
 
 
- 
whenNotMatched
public MergeOptions whenNotMatched(MergeOptions.WhenNotMatched whenNotMatched)
Sets the behavior of $merge if a result document does not match an existing document in the out collection.- Parameters:
 whenNotMatched- when not matched- Returns:
 - this
 
 
 - 
 
 -