5858public class DataLoader <K , V > {
5959
6060 private final DataLoaderHelper <K , V > helper ;
61- private final DataLoaderOptions loaderOptions ;
6261 private final CacheMap <Object , CompletableFuture <V >> futureCache ;
6362 private final StatisticsCollector stats ;
6463
@@ -246,7 +245,6 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
246245 * @return a new DataLoader
247246 * @see #newDataLoaderWithTry(BatchLoader)
248247 */
249- @ SuppressWarnings ("unchecked" )
250248 public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoader <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
251249 return new DataLoader <>(batchLoadFunction , options );
252250 }
@@ -309,7 +307,6 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
309307 * @return a new DataLoader
310308 * @see #newDataLoaderWithTry(BatchLoader)
311309 */
312- @ SuppressWarnings ("unchecked" )
313310 public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoaderWithContext <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
314311 return new DataLoader <>(batchLoadFunction , options );
315312 }
@@ -334,12 +331,12 @@ public DataLoader(BatchLoader<K, V> batchLoadFunction, DataLoaderOptions options
334331 }
335332
336333 private DataLoader (Object batchLoadFunction , DataLoaderOptions options ) {
337- this . loaderOptions = options == null ? new DataLoaderOptions () : options ;
334+ DataLoaderOptions loaderOptions = options == null ? new DataLoaderOptions () : options ;
338335 this .futureCache = determineCacheMap (loaderOptions );
339336 // order of keys matter in data loader
340- this .stats = nonNull (this . loaderOptions .getStatisticsCollector ());
337+ this .stats = nonNull (loaderOptions .getStatisticsCollector ());
341338
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 );
343340 }
344341
345342 @ SuppressWarnings ("unchecked" )
@@ -496,10 +493,8 @@ public DispatchResult<V> dispatchWithCounts() {
496493 * @return the list of all results when the {@link #dispatchDepth()} reached 0
497494 */
498495 public List <V > dispatchAndJoin () {
499- List <V > results = new ArrayList <>();
500-
501496 List <V > joinedResults = dispatch ().join ();
502- results . addAll (joinedResults );
497+ List < V > results = new ArrayList <> (joinedResults );
503498 while (this .dispatchDepth () > 0 ) {
504499 joinedResults = dispatch ().join ();
505500 results .addAll (joinedResults );
0 commit comments