public static class Distinct.Builder extends Object
Distinct object.| Modifier and Type | Field and Description |
|---|---|
protected String |
myKey
The name of the key to collect distinct values for.
|
protected long |
myMaximumTimeMilliseconds
The maximum amount of time to allow the command to run.
|
protected Document |
myQuery
The query to select document to perform a distinct query across.
|
protected ReadPreference |
myReadPreference
The read preference to use.
|
| Constructor and Description |
|---|
Distinct.Builder()
Creates a new Builder.
|
| Modifier and Type | Method and Description |
|---|---|
Distinct |
build()
Creates a new
GroupBy based on the current state of the
builder. |
Distinct.Builder |
key(String key)
Sets the name of the key to collect distinct values for.
|
Distinct.Builder |
maximumTime(long timeLimit,
TimeUnit timeLimitUnits)
Sets the maximum number of milliseconds to allow the command to run
before aborting the request on the server.
|
Distinct.Builder |
query(DocumentAssignable query)
Sets the value of the query to select the documents to run the
distinct against.
|
Distinct.Builder |
readPreference(ReadPreference readPreference)
Sets the
ReadPreference specifying which servers may be used
to execute the Distinct command. |
Distinct.Builder |
reset()
Resets the builder back to its initial state.
|
Distinct.Builder |
setKey(String key)
Sets the name of the key to collect distinct values for.
|
Distinct.Builder |
setMaximumTimeMilliseconds(long maximumTimeMilliseconds)
Sets the maximum number of milliseconds to allow the command to run
before aborting the request on the server.
|
Distinct.Builder |
setQuery(DocumentAssignable query)
Sets the value of the query to select the documents to run the
distinct against.
|
Distinct.Builder |
setReadPreference(ReadPreference readPreference)
Sets the
ReadPreference specifying which servers may be used
to execute the Distinct command. |
protected String myKey
protected long myMaximumTimeMilliseconds
protected Document myQuery
protected ReadPreference myReadPreference
public Distinct 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 key is null
or empty.public Distinct.Builder key(String key)
This method delegates to setKey(String).
key - The new name of the key to collect distinct values for.Distinct.Builder for method call chaining.public Distinct.Builder maximumTime(long timeLimit, TimeUnit timeLimitUnits)
This method equivalent to setMaximumTimeMilliseconds(timeLimitUnits.toMillis(timeLimit).
timeLimit - The new maximum amount of time to allow the command to
run.timeLimitUnits - The units for the maximum amount of time to allow the
command to run.Distinct.Builder for method call chaining.public Distinct.Builder query(DocumentAssignable query)
This method delegates to setQuery(DocumentAssignable).
query - The new value for the query to select the documents to run
the distinct against.Distinct.Builder for method call chaining.public Distinct.Builder readPreference(ReadPreference readPreference)
ReadPreference specifying which servers may be used
to execute the Distinct 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 Distinct.Builder reset()
Distinct.Builder for method call chaining.public Distinct.Builder setKey(String key)
key - The new name of the key to collect distinct values for.Distinct.Builder for method call chaining.public Distinct.Builder setMaximumTimeMilliseconds(long maximumTimeMilliseconds)
maximumTimeMilliseconds - The new maximum number of milliseconds to allow the
command to run.Distinct.Builder for method call chaining.public Distinct.Builder setQuery(DocumentAssignable query)
query - The new value for the query to select the documents to run
the distinct against.Distinct.Builder for method call chaining.public Distinct.Builder setReadPreference(ReadPreference readPreference)
ReadPreference specifying which servers may be used
to execute the Distinct 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()Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.