public static class FindAndModify.Builder extends Object
FindAndModify
commands.Modifier and Type | Field and Description |
---|---|
protected Document |
myFields
Retrieve a subset of fields from the matched document.
|
protected Document |
myQuery
A query to locate the document to update.
|
protected boolean |
myRemove
Set to a true to remove the object before returning
|
protected boolean |
myReturnNew
Set to true if you want to return the modified object rather than the
original.
|
protected Document |
mySort
If multiple docs match, choose the first one in the specified sort
order as the object to manipulate.
|
protected Document |
myUpdate
Updates to be applied to the document.
|
protected boolean |
myUpsert
Create object if it doesn't exist.
|
Constructor and Description |
---|
FindAndModify.Builder()
Creates a new Builder.
|
Modifier and Type | Method and Description |
---|---|
FindAndModify |
build()
Constructs a new
FindAndModify object from the state of the
builder. |
FindAndModify.Builder |
fields(DocumentAssignable fields)
Sets the subset of fields to retrieve from the matched document.
|
FindAndModify.Builder |
query(DocumentAssignable query)
Sets the query to locate the document to update.
|
FindAndModify.Builder |
remove()
Sets to true if the document should be removed.
|
FindAndModify.Builder |
remove(boolean remove)
Sets to true if the document should be removed.
|
FindAndModify.Builder |
reset()
Resets the builder back to its initial state.
|
FindAndModify.Builder |
returnNew()
Sets to true if the updated document should be returned instead of
the document before the update.
|
FindAndModify.Builder |
returnNew(boolean returnNew)
Sets to true if the updated document should be returned instead of
the document before the update.
|
FindAndModify.Builder |
setFields(DocumentAssignable fields)
Sets the subset of fields to retrieve from the matched document.
|
FindAndModify.Builder |
setQuery(DocumentAssignable query)
Sets the query to locate the document to update.
|
FindAndModify.Builder |
setRemove(boolean remove)
Sets to true if the document should be removed.
|
FindAndModify.Builder |
setReturnNew(boolean returnNew)
Sets to true if the updated document should be returned instead of
the document before the update.
|
FindAndModify.Builder |
setSort(DocumentAssignable sort)
Sets the sort to apply if multiple docs match, choose the first one
as the object to manipulate.
|
FindAndModify.Builder |
setSort(IntegerElement... sortFields)
Sets the sort to apply if multiple docs match, choose the first one
as the object to manipulate.
|
FindAndModify.Builder |
setUpdate(DocumentAssignable update)
Sets the updates to be applied to the document.
|
FindAndModify.Builder |
setUpsert(boolean upsert)
Sets to true to create the document if it doesn't exist.
|
FindAndModify.Builder |
sort(DocumentAssignable sort)
Sets the sort to apply if multiple docs match, choose the first one
as the object to manipulate.
|
FindAndModify.Builder |
sort(IntegerElement... sortFields)
Sets the sort to apply if multiple docs match, choose the first one
as the object to manipulate.
|
FindAndModify.Builder |
update(DocumentAssignable update)
Sets the updates to be applied to the document.
|
FindAndModify.Builder |
upsert()
Sets to true to create the document if it doesn't exist.
|
FindAndModify.Builder |
upsert(boolean upsert)
Sets to true to create the document if it doesn't exist.
|
protected Document myFields
protected Document myQuery
protected boolean myRemove
protected boolean myReturnNew
protected Document mySort
protected Document myUpdate
protected boolean myUpsert
public FindAndModify build()
FindAndModify
object from the state of the
builder.FindAndModify
object.public FindAndModify.Builder fields(DocumentAssignable fields)
This method delegates to setFields(DocumentAssignable)
.
fields
- The subset of fields to retrieve from the matched
document.public FindAndModify.Builder query(DocumentAssignable query)
This method delegates to setQuery(DocumentAssignable)
.
query
- The query to locate the document to update.public FindAndModify.Builder remove()
This method delegates to setRemove(true)
.
public FindAndModify.Builder remove(boolean remove)
This method delegates to setRemove(boolean)
.
remove
- True if the document should be removed.public FindAndModify.Builder reset()
FindAndModify.Builder
for method call chaining.public FindAndModify.Builder returnNew()
This method delegates to setReturnNew(true)
.
public FindAndModify.Builder returnNew(boolean returnNew)
This method delegates to setReturnNew(boolean)
.
returnNew
- True if the updated document should be returned instead of
the document before the update.public FindAndModify.Builder setFields(DocumentAssignable fields)
fields
- The subset of fields to retrieve from the matched
document.public FindAndModify.Builder setQuery(DocumentAssignable query)
query
- The query to locate the document to update.public FindAndModify.Builder setRemove(boolean remove)
remove
- True if the document should be removed.public FindAndModify.Builder setReturnNew(boolean returnNew)
returnNew
- True if the updated document should be returned instead of
the document before the update.public FindAndModify.Builder setSort(DocumentAssignable sort)
sort
- The sort to apply if multiple docs match, choose the first
one as the object to manipulate.public FindAndModify.Builder setSort(IntegerElement... sortFields)
This method is intended to be used with the Sort
class's
static methods:
import static
com.allanbank.mongodb.builder.Sort.asc
; import staticcom.allanbank.mongodb.builder.Sort.desc
; FindAndModify.Builder builder = new Find.Builder(); builder.setSort( asc("f"), desc("g") ); ...
sortFields
- The sort to apply if multiple docs match, choose the first
one as the object to manipulate.public FindAndModify.Builder setUpdate(DocumentAssignable update)
update
- The updates to be applied to the document.public FindAndModify.Builder setUpsert(boolean upsert)
upsert
- True to create the document if it doesn't exist.public FindAndModify.Builder sort(DocumentAssignable sort)
This method delegates to setSort(DocumentAssignable)
.
sort
- The sort to apply if multiple docs match, choose the first
one as the object to manipulate.public FindAndModify.Builder sort(IntegerElement... sortFields)
This method delegates to setSort(IntegerElement...)
.
This method is intended to be used with the Sort
class's
static methods:
import static
com.allanbank.mongodb.builder.Sort.asc
; import staticcom.allanbank.mongodb.builder.Sort.desc
; FindAndModify.Builder builder = new Find.Builder(); builder.sort( asc("f"), desc("g") ); ...
sortFields
- The sort to apply if multiple docs match, choose the first
one as the object to manipulate.public FindAndModify.Builder update(DocumentAssignable update)
This method delegates to setUpdate(DocumentAssignable)
.
update
- The updates to be applied to the document.public FindAndModify.Builder upsert()
This method delegates to setUpsert(true)
.
public FindAndModify.Builder upsert(boolean upsert)
This method delegates to setUpsert(boolean)
.
upsert
- True to create the document if it doesn't exist.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.