public static class GroupBy.Builder extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
myFinalizeFunction
The finalizer function to run for each group.
|
protected Document |
myInitialValue
The initial value for the group.
|
protected String |
myKeyFunction
Function to return the key for a document.
|
protected Set<String> |
myKeys
The fields to group by.
|
protected Document |
myQuery
The query to select the documents to run the group against.
|
protected ReadPreference |
myReadPreference
The read preference to use.
|
protected String |
myReduceFunction
The reduce function taking the previous value and the current value
and returning the new reduced value.
|
| Constructor and Description |
|---|
GroupBy.Builder()
Creates a new Builder.
|
| Modifier and Type | Method and Description |
|---|---|
GroupBy |
build()
Creates a new
GroupBy based on the current state of the
builder. |
GroupBy.Builder |
setFinalizeFunction(String finalizeFunction)
Sets the value of the finalizer function to run for each group.
|
GroupBy.Builder |
setInitialValue(DocumentAssignable initialValue)
Sets the value of the initial value for the group.
|
GroupBy.Builder |
setKeyFunction(String keyFunction)
Sets the value of the function to return the key for a document.
|
GroupBy.Builder |
setKeys(Set<String> keys)
Sets the fields to group by
|
GroupBy.Builder |
setQuery(DocumentAssignable query)
Sets the value of the query to select the documents to run the group
against.
|
GroupBy.Builder |
setReadPreference(ReadPreference readPreference)
Sets the
ReadPreference specifying which servers may be used
to execute the GroupBy command. |
GroupBy.Builder |
setReduceFunction(String reduceFunction)
Sets the value of the reduce function taking the previous value and
the current value and returning the new reduced value.
|
protected String myFinalizeFunction
protected Document myInitialValue
protected String myKeyFunction
setKeys(java.util.Set<java.lang.String>) to dynamically determine the group for each
document.protected Document myQuery
protected ReadPreference myReadPreference
protected String myReduceFunction
public GroupBy build() throws AssertionError
GroupBy based on the current state of the
builder.GroupBy based on the current state of the
builder.AssertionError - If neither the keys nor
key function have been set.public GroupBy.Builder setFinalizeFunction(String finalizeFunction)
finalizeFunction - The new value for the finalizer function to run for each
group.GroupBy.Builder for method call chaining.public GroupBy.Builder setInitialValue(DocumentAssignable initialValue)
initialValue - The new value for the initial value for the group.GroupBy.Builder for method call chaining.public GroupBy.Builder setKeyFunction(String keyFunction)
setKeys(java.util.Set<java.lang.String>) to dynamically determine the group
for each document.keyFunction - The new value for the function to return the key for a
document. Used instead of the setKeys(java.util.Set<java.lang.String>) to
dynamically determine the group for each document.GroupBy.Builder for method call chaining.public GroupBy.Builder setKeys(Set<String> keys)
keys - The new fields to group byGroupBy.Builder for method call chaining.public GroupBy.Builder setQuery(DocumentAssignable query)
query - The new value for the query to select the documents to run
the group against.GroupBy.Builder for method call chaining.public GroupBy.Builder setReadPreference(ReadPreference readPreference)
ReadPreference specifying which servers may be used
to execute the GroupBy command.
If not set or set to null then the
MongoCollection instance's ReadPreference will be
used.
readPreference - The read preferences specifying which servers may be used.MongoCollection.getReadPreference()public GroupBy.Builder setReduceFunction(String reduceFunction)
reduceFunction - The new value for the reduce function taking the previous
value and the current value and returning the new reduced
value.GroupBy.Builder for method call chaining.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.