|
1 | 1 | package graphql.schema;
|
2 | 2 |
|
3 |
| -import static graphql.Assert.assertNotNull; |
| 3 | +import graphql.PublicApi; |
4 | 4 |
|
5 | 5 | import java.util.concurrent.CompletableFuture;
|
6 | 6 | import java.util.concurrent.Executor;
|
7 | 7 | import java.util.concurrent.ForkJoinPool;
|
8 | 8 |
|
9 |
| -import graphql.PublicApi; |
| 9 | +import static graphql.Assert.assertNotNull; |
10 | 10 |
|
11 | 11 | /**
|
12 | 12 | * A modifier type that indicates the underlying data fetcher is run asynchronously
|
13 | 13 | */
|
14 | 14 | @PublicApi
|
15 |
| -public class AsynchronousDataFetcher<T> implements DataFetcher<CompletableFuture<T>> { |
16 |
| - |
| 15 | +public class AsyncDataFetcher<T> implements DataFetcher<CompletableFuture<T>> { |
| 16 | + |
17 | 17 | /**
|
18 |
| - * A factory method for creating asynchronous data fetchers so that when used with |
| 18 | + * A factory method for creating asynchronous data fetchers so that when used with |
19 | 19 | * static imports allows more readable code such as:
|
20 | 20 | * <p>
|
21 | 21 | * {@code .dataFetcher(async(fooDataFetcher))}
|
22 | 22 | * <p>
|
23 |
| - * By default this will run in the {@link ForkJoinPool#commonPool()}. You can set |
24 |
| - * your own {@link Executor} with {@link #asyncWithExecutor(DataFetcher, Executor)} |
| 23 | + * By default this will run in the {@link ForkJoinPool#commonPool()}. You can set |
| 24 | + * your own {@link Executor} with {@link #async(DataFetcher)} (DataFetcher, Executor)} |
25 | 25 | *
|
26 | 26 | * @param wrappedDataFetcher the data fetcher to run asynchronously
|
27 | 27 | *
|
28 | 28 | * @return a {@link DataFetcher} that will run the wrappedDataFetcher asynchronously
|
29 | 29 | */
|
30 |
| - public static <T> AsynchronousDataFetcher<T> async(DataFetcher<T> wrappedDataFetcher) { |
31 |
| - return new AsynchronousDataFetcher<>(wrappedDataFetcher); |
| 30 | + public static <T> AsyncDataFetcher<T> async(DataFetcher<T> wrappedDataFetcher) { |
| 31 | + return new AsyncDataFetcher<>(wrappedDataFetcher); |
32 | 32 | }
|
33 |
| - |
| 33 | + |
34 | 34 | /**
|
35 |
| - * A factory method for creating asynchronous data fetchers and setting the |
36 |
| - * {@link Executor} they run in so that when used with static imports allows |
| 35 | + * A factory method for creating asynchronous data fetchers and setting the |
| 36 | + * {@link Executor} they run in so that when used with static imports allows |
37 | 37 | * more readable code such as:
|
38 | 38 | * <p>
|
39 |
| - * {@code .dataFetcher(asyncWithExecutor(fooDataFetcher, fooPool))} |
| 39 | + * {@code .dataFetcher(async(fooDataFetcher, fooExecutor))} |
40 | 40 | *
|
41 | 41 | * @param wrappedDataFetcher the data fetcher to run asynchronously
|
42 |
| - * @param executor to run the asynchronous data fetcher in |
| 42 | + * @param executor the executor to run the asynchronous data fetcher in |
43 | 43 | *
|
44 |
| - * @return a {@link DataFetcher} that will run the wrappedDataFetcher asynchronously in |
| 44 | + * @return a {@link DataFetcher} that will run the wrappedDataFetcher asynchronously in |
45 | 45 | * the given {@link Executor}
|
46 | 46 | */
|
47 |
| - public static <T> AsynchronousDataFetcher<T> asyncWithExecutor(DataFetcher<T> wrappedDataFetcher, |
48 |
| - Executor executor) { |
49 |
| - return new AsynchronousDataFetcher<>(wrappedDataFetcher, executor); |
| 47 | + public static <T> AsyncDataFetcher<T> async(DataFetcher<T> wrappedDataFetcher, Executor executor) { |
| 48 | + return new AsyncDataFetcher<>(wrappedDataFetcher, executor); |
50 | 49 | }
|
51 |
| - |
| 50 | + |
52 | 51 | private final DataFetcher<T> wrappedDataFetcher;
|
53 | 52 | private final Executor executor;
|
54 | 53 |
|
55 |
| - public AsynchronousDataFetcher(DataFetcher<T> wrappedDataFetcher) { |
| 54 | + public AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher) { |
56 | 55 | this(wrappedDataFetcher, ForkJoinPool.commonPool());
|
57 | 56 | }
|
58 | 57 |
|
59 |
| - public AsynchronousDataFetcher(DataFetcher<T> wrappedDataFetcher, Executor executor) { |
| 58 | + public AsyncDataFetcher(DataFetcher<T> wrappedDataFetcher, Executor executor) { |
60 | 59 | this.wrappedDataFetcher = assertNotNull(wrappedDataFetcher, "wrappedDataFetcher can't be null");
|
61 | 60 | this.executor = assertNotNull(executor, "executor can't be null");
|
62 | 61 | }
|
|
0 commit comments