Skip to content

Commit 08f94b3

Browse files
committed
Updated names / documentation based on new conventions
Refs: JAVA-1659
1 parent 7e28449 commit 08f94b3

18 files changed

+138
-183
lines changed

driver-async/src/main/com/mongodb/async/client/FindIterableImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.mongodb.operation.AsyncOperationExecutor;
2828
import com.mongodb.operation.FindOperation;
2929
import org.bson.BsonDocument;
30-
import org.bson.codecs.Codec;
3130
import org.bson.codecs.configuration.CodecRegistry;
3231
import org.bson.conversions.Bson;
3332

@@ -166,12 +165,8 @@ private MongoIterable<TResult> execute(final FindOperation<TResult> operation) {
166165
return new OperationIterable<TResult>(operation, readPreference, executor);
167166
}
168167

169-
private <C> Codec<C> getCodec(final Class<C> clazz) {
170-
return codecRegistry.get(clazz);
171-
}
172-
173168
private FindOperation<TResult> createQueryOperation() {
174-
return new FindOperation<TResult>(namespace, getCodec(resultClass))
169+
return new FindOperation<TResult>(namespace, codecRegistry.get(resultClass))
175170
.filter(toBsonDocument(filter))
176171
.batchSize(findOptions.getBatchSize())
177172
.skip(findOptions.getSkip())

driver-async/src/main/com/mongodb/async/client/ListCollectionsIterableImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.mongodb.operation.AsyncOperationExecutor;
2525
import com.mongodb.operation.ListCollectionsOperation;
2626
import org.bson.BsonDocument;
27-
import org.bson.codecs.Codec;
2827
import org.bson.codecs.configuration.CodecRegistry;
2928
import org.bson.conversions.Bson;
3029

@@ -107,12 +106,8 @@ private MongoIterable<TResult> execute(final ListCollectionsOperation<TResult> o
107106
return new OperationIterable<TResult>(operation, readPreference, executor);
108107
}
109108

110-
private <C> Codec<C> getCodec(final Class<C> clazz) {
111-
return codecRegistry.get(clazz);
112-
}
113-
114109
private ListCollectionsOperation<TResult> createListCollectionsOperation() {
115-
return new ListCollectionsOperation<TResult>(databaseName, getCodec(resultClass))
110+
return new ListCollectionsOperation<TResult>(databaseName, codecRegistry.get(resultClass))
116111
.filter(toBsonDocument(filter))
117112
.batchSize(batchSize)
118113
.maxTime(maxTimeMS, MILLISECONDS);

driver-async/src/main/com/mongodb/async/client/ListDatabasesIterableImpl.java

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
import com.mongodb.Block;
2020
import com.mongodb.Function;
2121
import com.mongodb.ReadPreference;
22-
import com.mongodb.async.SingleResultCallback;
2322
import com.mongodb.async.AsyncBatchCursor;
23+
import com.mongodb.async.SingleResultCallback;
2424
import com.mongodb.operation.AsyncOperationExecutor;
2525
import com.mongodb.operation.ListDatabasesOperation;
26-
import org.bson.codecs.Codec;
2726
import org.bson.codecs.configuration.CodecRegistry;
2827

2928
import java.util.Collection;
@@ -32,73 +31,69 @@
3231
import static com.mongodb.assertions.Assertions.notNull;
3332
import static java.util.concurrent.TimeUnit.MILLISECONDS;
3433

35-
final class ListDatabasesIterableImpl<T> implements ListDatabasesIterable<T> {
36-
private final Class<T> clazz;
34+
final class ListDatabasesIterableImpl<TResult> implements ListDatabasesIterable<TResult> {
35+
private final Class<TResult> resultClass;
3736
private final ReadPreference readPreference;
3837
private final CodecRegistry codecRegistry;
3938
private final AsyncOperationExecutor executor;
4039

4140
private long maxTimeMS;
4241

43-
ListDatabasesIterableImpl(final Class<T> clazz, final CodecRegistry codecRegistry,
42+
ListDatabasesIterableImpl(final Class<TResult> resultClass, final CodecRegistry codecRegistry,
4443
final ReadPreference readPreference, final AsyncOperationExecutor executor) {
45-
this.clazz = notNull("clazz", clazz);
44+
this.resultClass = notNull("resultClass", resultClass);
4645
this.codecRegistry = notNull("codecRegistry", codecRegistry);
4746
this.readPreference = notNull("readPreference", readPreference);
4847
this.executor = notNull("executor", executor);
4948
}
5049

5150
@Override
52-
public ListDatabasesIterable<T> maxTime(final long maxTime, final TimeUnit timeUnit) {
51+
public ListDatabasesIterable<TResult> maxTime(final long maxTime, final TimeUnit timeUnit) {
5352
notNull("timeUnit", timeUnit);
5453
this.maxTimeMS = MILLISECONDS.convert(maxTime, timeUnit);
5554
return this;
5655
}
5756

5857
@Override
59-
public void first(final SingleResultCallback<T> callback) {
58+
public void first(final SingleResultCallback<TResult> callback) {
6059
execute(createListDatabasesOperation()).first(callback);
6160
}
6261

6362
@Override
64-
public void forEach(final Block<? super T> block, final SingleResultCallback<Void> callback) {
63+
public void forEach(final Block<? super TResult> block, final SingleResultCallback<Void> callback) {
6564
execute().forEach(block, callback);
6665
}
6766

6867
@Override
69-
public <A extends Collection<? super T>> void into(final A target, final SingleResultCallback<A> callback) {
68+
public <A extends Collection<? super TResult>> void into(final A target, final SingleResultCallback<A> callback) {
7069
execute().into(target, callback);
7170
}
7271

7372
@Override
74-
public <U> MongoIterable<U> map(final Function<T, U> mapper) {
75-
return new MappingIterable<T, U>(this, mapper);
73+
public <U> MongoIterable<U> map(final Function<TResult, U> mapper) {
74+
return new MappingIterable<TResult, U>(this, mapper);
7675
}
7776

7877
@Override
79-
public ListDatabasesIterableImpl<T> batchSize(final int batchSize) {
78+
public ListDatabasesIterableImpl<TResult> batchSize(final int batchSize) {
8079
// Noop - not supported by listDatabasesIterable
8180
return this;
8281
}
8382

8483
@Override
85-
public void batchCursor(final SingleResultCallback<AsyncBatchCursor<T>> callback) {
84+
public void batchCursor(final SingleResultCallback<AsyncBatchCursor<TResult>> callback) {
8685
execute().batchCursor(callback);
8786
}
8887

89-
private MongoIterable<T> execute() {
88+
private MongoIterable<TResult> execute() {
9089
return execute(createListDatabasesOperation());
9190
}
9291

93-
private MongoIterable<T> execute(final ListDatabasesOperation<T> operation) {
94-
return new OperationIterable<T>(operation, readPreference, executor);
95-
}
96-
97-
private <C> Codec<C> getCodec(final Class<C> clazz) {
98-
return codecRegistry.get(clazz);
92+
private MongoIterable<TResult> execute(final ListDatabasesOperation<TResult> operation) {
93+
return new OperationIterable<TResult>(operation, readPreference, executor);
9994
}
10095

101-
private ListDatabasesOperation<T> createListDatabasesOperation() {
102-
return new ListDatabasesOperation<T>(getCodec(clazz)).maxTime(maxTimeMS, MILLISECONDS);
96+
private ListDatabasesOperation<TResult> createListDatabasesOperation() {
97+
return new ListDatabasesOperation<TResult>(codecRegistry.get(resultClass)).maxTime(maxTimeMS, MILLISECONDS);
10398
}
10499
}

driver-async/src/main/com/mongodb/async/client/ListIndexesIterableImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import com.mongodb.async.SingleResultCallback;
2525
import com.mongodb.operation.AsyncOperationExecutor;
2626
import com.mongodb.operation.ListIndexesOperation;
27-
import org.bson.codecs.Codec;
2827
import org.bson.codecs.configuration.CodecRegistry;
2928

3029
import java.util.Collection;
@@ -98,12 +97,8 @@ private MongoIterable<TResult> execute(final ListIndexesOperation<TResult> opera
9897
return new OperationIterable<TResult>(operation, readPreference, executor);
9998
}
10099

101-
private <C> Codec<C> getCodec(final Class<C> clazz) {
102-
return codecRegistry.get(clazz);
103-
}
104-
105100
private ListIndexesOperation<TResult> createListIndexesOperation() {
106-
return new ListIndexesOperation<TResult>(namespace, getCodec(resultClass))
101+
return new ListIndexesOperation<TResult>(namespace, codecRegistry.get(resultClass))
107102
.batchSize(batchSize)
108103
.maxTime(maxTimeMS, MILLISECONDS);
109104
}

driver-async/src/main/com/mongodb/async/client/MongoClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public interface MongoClient extends Closeable {
7373
/**
7474
* Gets the list of databases
7575
*
76-
* @param clazz the class to cast the database documents to
77-
* @param <T> the type of the class to use instead of {@code Document}.
76+
* @param resultClass the class to cast the database documents to
77+
* @param <TResult> the type of the class to use instead of {@code Document}.
7878
* @return the list databases iterable interface
7979
*/
80-
<T> ListDatabasesIterable<T> listDatabases(Class<T> clazz);
80+
<TResult> ListDatabasesIterable<TResult> listDatabases(Class<TResult> resultClass);
8181

8282
}

driver-async/src/main/com/mongodb/async/client/MongoClientImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ public ListDatabasesIterable<Document> listDatabases() {
107107
}
108108

109109
@Override
110-
public <T> ListDatabasesIterable<T> listDatabases(final Class<T> clazz) {
111-
return new ListDatabasesIterableImpl<T>(clazz, options.getCodecRegistry(), ReadPreference.primary(), executor);
110+
public <T> ListDatabasesIterable<T> listDatabases(final Class<T> resultClass) {
111+
return new ListDatabasesIterableImpl<T>(resultClass, options.getCodecRegistry(), ReadPreference.primary(), executor);
112112
}
113113

114114
Cluster getCluster() {

driver-async/src/main/com/mongodb/async/client/MongoCollection.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
/**
4444
* The MongoCollection interface.
45-
*
45+
* <p/>
4646
* <p>Note: Additions to this interface will not be considered to break binary compatibility.</p>
4747
*
4848
* @param <TDocument> The type that this collection will encode documents from and decode documents to.
@@ -89,11 +89,11 @@ public interface MongoCollection<TDocument> {
8989
/**
9090
* Create a new MongoCollection instance with a different default class to cast any documents returned from the database into..
9191
*
92-
* @param clazz the default class to cast any documents returned from the database into.
93-
* @param <NewTDocument> The type that the new collection will encode documents from and decode documents to
92+
* @param newDocumentClass the default class to cast any documents returned from the database into.
93+
* @param <NewTDocument> the type that the new collection will encode documents from and decode documents to
9494
* @return a new MongoCollection instance with the different default class
9595
*/
96-
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> clazz);
96+
<NewTDocument> MongoCollection<NewTDocument> withDocumentClass(Class<NewTDocument> newDocumentClass);
9797

9898
/**
9999
* Create a new MongoCollection instance with a different codec registry.
@@ -146,13 +146,13 @@ public interface MongoCollection<TDocument> {
146146
/**
147147
* Gets the distinct values of the specified field name.
148148
*
149-
* @param fieldName the field name
150-
* @param clazz the default class to cast any distinct items into.
151-
* @param <TResult> the target type of the iterable.
149+
* @param fieldName the field name
150+
* @param resultClass the default class to cast any distinct items into.
151+
* @param <TResult> the target type of the iterable.
152152
* @return an iterable of distinct values
153153
* @mongodb.driver.manual reference/command/distinct/ Distinct
154154
*/
155-
<TResult> DistinctIterable<TResult> distinct(String fieldName, Class<TResult> clazz);
155+
<TResult> DistinctIterable<TResult> distinct(String fieldName, Class<TResult> resultClass);
156156

157157
/**
158158
* Finds all documents in the collection.
@@ -165,12 +165,12 @@ public interface MongoCollection<TDocument> {
165165
/**
166166
* Finds all documents in the collection.
167167
*
168-
* @param clazz the class to decode each document into
168+
* @param resultClass the class to decode each document into
169169
* @param <TResult> the target document type of the iterable.
170170
* @return the find iterable interface
171171
* @mongodb.driver.manual tutorial/query-documents/ Find
172172
*/
173-
<TResult> FindIterable<TResult> find(Class<TResult> clazz);
173+
<TResult> FindIterable<TResult> find(Class<TResult> resultClass);
174174

175175
/**
176176
* Finds all documents in the collection.
@@ -184,13 +184,13 @@ public interface MongoCollection<TDocument> {
184184
/**
185185
* Finds all documents in the collection.
186186
*
187-
* @param filter the query filter
188-
* @param clazz the class to decode each document into
189-
* @param <TResult> the target document type of the iterable.
187+
* @param filter the query filter
188+
* @param resultClass the class to decode each document into
189+
* @param <TResult> the target document type of the iterable.
190190
* @return the find iterable interface
191191
* @mongodb.driver.manual tutorial/query-documents/ Find
192192
*/
193-
<TResult> FindIterable<TResult> find(Bson filter, Class<TResult> clazz);
193+
<TResult> FindIterable<TResult> find(Bson filter, Class<TResult> resultClass);
194194

195195
/**
196196
* Aggregates documents according to the specified aggregation pipeline. If the pipeline ends with a $out stage, the returned
@@ -208,13 +208,13 @@ public interface MongoCollection<TDocument> {
208208
* iterable will be a query of the collection that the aggregation was written to. Note that in this case the pipeline will be
209209
* executed even if the iterable is never iterated.
210210
*
211-
* @param pipeline the aggregate pipeline
212-
* @param clazz the class to decode each document into
213-
* @param <TResult> the target document type of the iterable.
211+
* @param pipeline the aggregate pipeline
212+
* @param resultClass the class to decode each document into
213+
* @param <TResult> the target document type of the iterable.
214214
* @return an iterable containing the result of the aggregation operation
215215
* @mongodb.driver.manual aggregation/ Aggregation
216216
*/
217-
<TResult> AggregateIterable<TResult> aggregate(List<? extends Bson> pipeline, Class<TResult> clazz);
217+
<TResult> AggregateIterable<TResult> aggregate(List<? extends Bson> pipeline, Class<TResult> resultClass);
218218

219219
/**
220220
* Aggregates documents according to the specified map-reduce function.
@@ -231,12 +231,12 @@ public interface MongoCollection<TDocument> {
231231
*
232232
* @param mapFunction A JavaScript function that associates or "maps" a value with a key and emits the key and value pair.
233233
* @param reduceFunction A JavaScript function that "reduces" to a single object all the values associated with a particular key.
234-
* @param clazz the class to decode each resulting document into.
235-
* @param <TResult> the target document type of the iterable.
234+
* @param resultClass the class to decode each resulting document into.
235+
* @param <TResult> the target document type of the iterable.
236236
* @return an iterable containing the result of the map-reduce operation
237237
* @mongodb.driver.manual reference/command/mapReduce/ map-reduce
238238
*/
239-
<TResult> MapReduceIterable<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> clazz);
239+
<TResult> MapReduceIterable<TResult> mapReduce(String mapFunction, String reduceFunction, Class<TResult> resultClass);
240240

241241
/**
242242
* Executes a mix of inserts, updates, replaces, and deletes.
@@ -500,12 +500,12 @@ void bulkWrite(List<? extends WriteModel<? extends TDocument>> requests, BulkWri
500500
/**
501501
* Get all the indexes in this collection.
502502
*
503-
* @param clazz the class to decode each document into
504-
* @param <TResult> the target document type of the iterable.
503+
* @param resultClass the class to decode each document into
504+
* @param <TResult> the target document type of the iterable.
505505
* @return the list indexes iterable interface
506506
* @mongodb.driver.manual reference/command/listIndexes/ listIndexes
507507
*/
508-
<TResult> ListIndexesIterable<TResult> listIndexes(Class<TResult> clazz);
508+
<TResult> ListIndexesIterable<TResult> listIndexes(Class<TResult> resultClass);
509509

510510
/**
511511
* Drops the given index.

driver-async/src/main/com/mongodb/async/client/MongoCollectionImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public WriteConcern getWriteConcern() {
121121
}
122122

123123
@Override
124-
public <NewTDocument> MongoCollection<NewTDocument> withDocumentClass(final Class<NewTDocument> documentClass) {
125-
return new MongoCollectionImpl<NewTDocument>(namespace, documentClass, codecRegistry, readPreference, writeConcern, executor);
124+
public <NewTDocument> MongoCollection<NewTDocument> withDocumentClass(final Class<NewTDocument> newDocumentClass) {
125+
return new MongoCollectionImpl<NewTDocument>(namespace, newDocumentClass, codecRegistry, readPreference, writeConcern, executor);
126126
}
127127

128128
@Override

0 commit comments

Comments
 (0)