58
58
public class DataLoader <K , V > {
59
59
60
60
private final DataLoaderHelper <K , V > helper ;
61
- private final DataLoaderOptions loaderOptions ;
62
61
private final CacheMap <Object , CompletableFuture <V >> futureCache ;
63
62
private final StatisticsCollector stats ;
64
63
@@ -246,7 +245,6 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
246
245
* @return a new DataLoader
247
246
* @see #newDataLoaderWithTry(BatchLoader)
248
247
*/
249
- @ SuppressWarnings ("unchecked" )
250
248
public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoader <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
251
249
return new DataLoader <>(batchLoadFunction , options );
252
250
}
@@ -309,7 +307,6 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
309
307
* @return a new DataLoader
310
308
* @see #newDataLoaderWithTry(BatchLoader)
311
309
*/
312
- @ SuppressWarnings ("unchecked" )
313
310
public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoaderWithContext <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
314
311
return new DataLoader <>(batchLoadFunction , options );
315
312
}
@@ -334,12 +331,12 @@ public DataLoader(BatchLoader<K, V> batchLoadFunction, DataLoaderOptions options
334
331
}
335
332
336
333
private DataLoader (Object batchLoadFunction , DataLoaderOptions options ) {
337
- this . loaderOptions = options == null ? new DataLoaderOptions () : options ;
334
+ DataLoaderOptions loaderOptions = options == null ? new DataLoaderOptions () : options ;
338
335
this .futureCache = determineCacheMap (loaderOptions );
339
336
// order of keys matter in data loader
340
- this .stats = nonNull (this . loaderOptions .getStatisticsCollector ());
337
+ this .stats = nonNull (loaderOptions .getStatisticsCollector ());
341
338
342
- this .helper = new DataLoaderHelper <>(this , batchLoadFunction , this . loaderOptions , this .futureCache , this .stats );
339
+ this .helper = new DataLoaderHelper <>(this , batchLoadFunction , loaderOptions , this .futureCache , this .stats );
343
340
}
344
341
345
342
@ SuppressWarnings ("unchecked" )
@@ -496,10 +493,8 @@ public DispatchResult<V> dispatchWithCounts() {
496
493
* @return the list of all results when the {@link #dispatchDepth()} reached 0
497
494
*/
498
495
public List <V > dispatchAndJoin () {
499
- List <V > results = new ArrayList <>();
500
-
501
496
List <V > joinedResults = dispatch ().join ();
502
- results . addAll (joinedResults );
497
+ List < V > results = new ArrayList <> (joinedResults );
503
498
while (this .dispatchDepth () > 0 ) {
504
499
joinedResults = dispatch ().join ();
505
500
results .addAll (joinedResults );
0 commit comments