5959 * @author <a href="https://github.com/aschrijver/">Arnold Schrijver</a>
6060 * @author <a href="https://github.com/bbakerman/">Brad Baker</a>
6161 */
62+ @ SuppressWarnings ("UnusedReturnValue" )
6263@ PublicApi
6364public class DataLoader <K , V > {
6465
@@ -75,7 +76,10 @@ public class DataLoader<K, V> {
7576 * @param <V> the value type
7677 *
7778 * @return a new DataLoader
79+ *
80+ * @deprecated use {@link DataLoaderFactory} instead
7881 */
82+ @ Deprecated
7983 public static <K , V > DataLoader <K , V > newDataLoader (BatchLoader <K , V > batchLoadFunction ) {
8084 return newDataLoader (batchLoadFunction , null );
8185 }
@@ -89,9 +93,12 @@ public static <K, V> DataLoader<K, V> newDataLoader(BatchLoader<K, V> batchLoadF
8993 * @param <V> the value type
9094 *
9195 * @return a new DataLoader
96+ *
97+ * @deprecated use {@link DataLoaderFactory} instead
9298 */
99+ @ Deprecated
93100 public static <K , V > DataLoader <K , V > newDataLoader (BatchLoader <K , V > batchLoadFunction , DataLoaderOptions options ) {
94- return new DataLoader <> (batchLoadFunction , options );
101+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
95102 }
96103
97104 /**
@@ -110,7 +117,10 @@ public static <K, V> DataLoader<K, V> newDataLoader(BatchLoader<K, V> batchLoadF
110117 * @param <V> the value type
111118 *
112119 * @return a new DataLoader
120+ *
121+ * @deprecated use {@link DataLoaderFactory} instead
113122 */
123+ @ Deprecated
114124 public static <K , V > DataLoader <K , V > newDataLoaderWithTry (BatchLoader <K , Try <V >> batchLoadFunction ) {
115125 return newDataLoaderWithTry (batchLoadFunction , null );
116126 }
@@ -127,11 +137,12 @@ public static <K, V> DataLoader<K, V> newDataLoaderWithTry(BatchLoader<K, Try<V>
127137 *
128138 * @return a new DataLoader
129139 *
130- * @see #newDataLoaderWithTry(BatchLoader)
140+ * @see DataLoaderFactory#newDataLoaderWithTry(BatchLoader)
141+ * @deprecated use {@link DataLoaderFactory} instead
131142 */
132- @ SuppressWarnings ( "unchecked" )
143+ @ Deprecated
133144 public static <K , V > DataLoader <K , V > newDataLoaderWithTry (BatchLoader <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
134- return new DataLoader <>(( BatchLoader < K , V >) batchLoadFunction , options );
145+ return DataLoaderFactory . mkDataLoader ( batchLoadFunction , options );
135146 }
136147
137148 /**
@@ -143,7 +154,10 @@ public static <K, V> DataLoader<K, V> newDataLoaderWithTry(BatchLoader<K, Try<V>
143154 * @param <V> the value type
144155 *
145156 * @return a new DataLoader
157+ *
158+ * @deprecated use {@link DataLoaderFactory} instead
146159 */
160+ @ Deprecated
147161 public static <K , V > DataLoader <K , V > newDataLoader (BatchLoaderWithContext <K , V > batchLoadFunction ) {
148162 return newDataLoader (batchLoadFunction , null );
149163 }
@@ -157,9 +171,12 @@ public static <K, V> DataLoader<K, V> newDataLoader(BatchLoaderWithContext<K, V>
157171 * @param <V> the value type
158172 *
159173 * @return a new DataLoader
174+ *
175+ * @deprecated use {@link DataLoaderFactory} instead
160176 */
177+ @ Deprecated
161178 public static <K , V > DataLoader <K , V > newDataLoader (BatchLoaderWithContext <K , V > batchLoadFunction , DataLoaderOptions options ) {
162- return new DataLoader <> (batchLoadFunction , options );
179+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
163180 }
164181
165182 /**
@@ -178,7 +195,10 @@ public static <K, V> DataLoader<K, V> newDataLoader(BatchLoaderWithContext<K, V>
178195 * @param <V> the value type
179196 *
180197 * @return a new DataLoader
198+ *
199+ * @deprecated use {@link DataLoaderFactory} instead
181200 */
201+ @ Deprecated
182202 public static <K , V > DataLoader <K , V > newDataLoaderWithTry (BatchLoaderWithContext <K , Try <V >> batchLoadFunction ) {
183203 return newDataLoaderWithTry (batchLoadFunction , null );
184204 }
@@ -195,10 +215,12 @@ public static <K, V> DataLoader<K, V> newDataLoaderWithTry(BatchLoaderWithContex
195215 *
196216 * @return a new DataLoader
197217 *
198- * @see #newDataLoaderWithTry(BatchLoader)
218+ * @see DataLoaderFactory#newDataLoaderWithTry(BatchLoader)
219+ * @deprecated use {@link DataLoaderFactory} instead
199220 */
221+ @ Deprecated
200222 public static <K , V > DataLoader <K , V > newDataLoaderWithTry (BatchLoaderWithContext <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
201- return new DataLoader <> (batchLoadFunction , options );
223+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
202224 }
203225
204226 /**
@@ -210,7 +232,10 @@ public static <K, V> DataLoader<K, V> newDataLoaderWithTry(BatchLoaderWithContex
210232 * @param <V> the value type
211233 *
212234 * @return a new DataLoader
235+ *
236+ * @deprecated use {@link DataLoaderFactory} instead
213237 */
238+ @ Deprecated
214239 public static <K , V > DataLoader <K , V > newMappedDataLoader (MappedBatchLoader <K , V > batchLoadFunction ) {
215240 return newMappedDataLoader (batchLoadFunction , null );
216241 }
@@ -224,9 +249,12 @@ public static <K, V> DataLoader<K, V> newMappedDataLoader(MappedBatchLoader<K, V
224249 * @param <V> the value type
225250 *
226251 * @return a new DataLoader
252+ *
253+ * @deprecated use {@link DataLoaderFactory} instead
227254 */
255+ @ Deprecated
228256 public static <K , V > DataLoader <K , V > newMappedDataLoader (MappedBatchLoader <K , V > batchLoadFunction , DataLoaderOptions options ) {
229- return new DataLoader <> (batchLoadFunction , options );
257+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
230258 }
231259
232260 /**
@@ -246,7 +274,10 @@ public static <K, V> DataLoader<K, V> newMappedDataLoader(MappedBatchLoader<K, V
246274 * @param <V> the value type
247275 *
248276 * @return a new DataLoader
277+ *
278+ * @deprecated use {@link DataLoaderFactory} instead
249279 */
280+ @ Deprecated
250281 public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoader <K , Try <V >> batchLoadFunction ) {
251282 return newMappedDataLoaderWithTry (batchLoadFunction , null );
252283 }
@@ -263,10 +294,12 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
263294 *
264295 * @return a new DataLoader
265296 *
266- * @see #newDataLoaderWithTry(BatchLoader)
297+ * @see DataLoaderFactory#newDataLoaderWithTry(BatchLoader)
298+ * @deprecated use {@link DataLoaderFactory} instead
267299 */
300+ @ Deprecated
268301 public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoader <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
269- return new DataLoader <> (batchLoadFunction , options );
302+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
270303 }
271304
272305 /**
@@ -278,7 +311,10 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
278311 * @param <V> the value type
279312 *
280313 * @return a new DataLoader
314+ *
315+ * @deprecated use {@link DataLoaderFactory} instead
281316 */
317+ @ Deprecated
282318 public static <K , V > DataLoader <K , V > newMappedDataLoader (MappedBatchLoaderWithContext <K , V > batchLoadFunction ) {
283319 return newMappedDataLoader (batchLoadFunction , null );
284320 }
@@ -292,9 +328,12 @@ public static <K, V> DataLoader<K, V> newMappedDataLoader(MappedBatchLoaderWithC
292328 * @param <V> the value type
293329 *
294330 * @return a new DataLoader
331+ *
332+ * @deprecated use {@link DataLoaderFactory} instead
295333 */
334+ @ Deprecated
296335 public static <K , V > DataLoader <K , V > newMappedDataLoader (MappedBatchLoaderWithContext <K , V > batchLoadFunction , DataLoaderOptions options ) {
297- return new DataLoader <> (batchLoadFunction , options );
336+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
298337 }
299338
300339 /**
@@ -313,7 +352,10 @@ public static <K, V> DataLoader<K, V> newMappedDataLoader(MappedBatchLoaderWithC
313352 * @param <V> the value type
314353 *
315354 * @return a new DataLoader
355+ *
356+ * @deprecated use {@link DataLoaderFactory} instead
316357 */
358+ @ Deprecated
317359 public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoaderWithContext <K , Try <V >> batchLoadFunction ) {
318360 return newMappedDataLoaderWithTry (batchLoadFunction , null );
319361 }
@@ -330,32 +372,40 @@ public static <K, V> DataLoader<K, V> newMappedDataLoaderWithTry(MappedBatchLoad
330372 *
331373 * @return a new DataLoader
332374 *
333- * @see #newDataLoaderWithTry(BatchLoader)
375+ * @see DataLoaderFactory#newDataLoaderWithTry(BatchLoader)
376+ * @deprecated use {@link DataLoaderFactory} instead
334377 */
378+ @ Deprecated
335379 public static <K , V > DataLoader <K , V > newMappedDataLoaderWithTry (MappedBatchLoaderWithContext <K , Try <V >> batchLoadFunction , DataLoaderOptions options ) {
336- return new DataLoader <> (batchLoadFunction , options );
380+ return DataLoaderFactory . mkDataLoader (batchLoadFunction , options );
337381 }
338382
339383 /**
340384 * Creates a new data loader with the provided batch load function, and default options.
341385 *
342386 * @param batchLoadFunction the batch load function to use
387+ *
388+ * @deprecated use {@link DataLoaderFactory} instead
343389 */
390+ @ Deprecated
344391 public DataLoader (BatchLoader <K , V > batchLoadFunction ) {
345- this (batchLoadFunction , null );
392+ this (( Object ) batchLoadFunction , null );
346393 }
347394
348395 /**
349396 * Creates a new data loader with the provided batch load function and options.
350397 *
351398 * @param batchLoadFunction the batch load function to use
352399 * @param options the batch load options
400+ *
401+ * @deprecated use {@link DataLoaderFactory} instead
353402 */
403+ @ Deprecated
354404 public DataLoader (BatchLoader <K , V > batchLoadFunction , DataLoaderOptions options ) {
355405 this ((Object ) batchLoadFunction , options );
356406 }
357407
358- private DataLoader (Object batchLoadFunction , DataLoaderOptions options ) {
408+ DataLoader (Object batchLoadFunction , DataLoaderOptions options ) {
359409 DataLoaderOptions loaderOptions = options == null ? new DataLoaderOptions () : options ;
360410 this .futureCache = determineCacheMap (loaderOptions );
361411 // order of keys matter in data loader
0 commit comments