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 |
finalize(String finalizeFunction)
Sets the value of the finalizer function to run for each group.
|
GroupBy.Builder |
initialValue(DocumentAssignable initialValue)
Sets the value of the initial value for the group.
|
GroupBy.Builder |
key(String keyFunction)
Sets the value of the function to return the key for a document.
|
GroupBy.Builder |
keys(Set<String> keys)
Sets the fields to group by
|
GroupBy.Builder |
query(DocumentAssignable query)
Sets the value of the query to select the documents to run the group
against.
|
GroupBy.Builder |
readPreference(ReadPreference readPreference)
Sets the
ReadPreference specifying which servers may be used
to execute the GroupBy command. |
GroupBy.Builder |
reduce(String reduceFunction)
Sets the value of the reduce function taking the previous value and
the current value and returning the new reduced value.
|
GroupBy.Builder |
reset()
Resets the builder back to its initial state.
|
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 IllegalArgumentException
GroupBy
based on the current state of the
builder.GroupBy
based on the current state of the
builder.IllegalArgumentException
- If neither the keys
nor
key function
have been set.public GroupBy.Builder finalize(String finalizeFunction)
This method delegates to setFinalizeFunction(String)
.
finalizeFunction
- The new value for the finalizer function to run for each
group.GroupBy.Builder
for method call chaining.public GroupBy.Builder initialValue(DocumentAssignable initialValue)
This method delegates to setInitialValue(DocumentAssignable)
.
initialValue
- The new value for the initial value for the group.GroupBy.Builder
for method call chaining.public GroupBy.Builder key(String keyFunction)
setKeys(java.util.Set<java.lang.String>)
to dynamically determine the group
for each document.
This method delegates to setKeyFunction(String)
.
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 keys(Set<String> keys)
This method delegates to setKeys(Set)
.
keys
- The new fields to group byGroupBy.Builder
for method call chaining.public GroupBy.Builder query(DocumentAssignable query)
This method delegates to setQuery(DocumentAssignable)
.
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 readPreference(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.
This method delegates to setReadPreference(ReadPreference)
.
readPreference
- The read preferences specifying which servers may be used.MongoCollection.getReadPreference()
public GroupBy.Builder reduce(String reduceFunction)
This method delegates to setReduceFunction(String)
.
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.public GroupBy.Builder reset()
GroupBy.Builder
for method call chaining.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.