|
15 | 15 | import static org.dataloader.impl.Assertions.nonNull; |
16 | 16 |
|
17 | 17 | /** |
18 | | - * This {@link DataLoaderRegistry} will use a {@link DispatchPredicate} when {@link #dispatchAll()} is called |
| 18 | + * This {@link DataLoaderRegistry} will use {@link DispatchPredicate}s when {@link #dispatchAll()} is called |
19 | 19 | * to test (for each {@link DataLoader} in the registry) if a dispatch should proceed. If the predicate returns false, then a task is scheduled |
20 | 20 | * to perform that predicate dispatch again via the {@link ScheduledExecutorService}. |
21 | 21 | * <p> |
| 22 | + * It;s possible to have a {@link DispatchPredicate} per dataloader as well as a default {@link DispatchPredicate} for the |
| 23 | + * whole {@link ScheduledDataLoaderRegistry}. |
| 24 | + * <p> |
22 | 25 | * This will continue to loop (test false and reschedule) until such time as the predicate returns true, in which case |
23 | | - * no rescheduling will occur and you will need to call dispatch again to restart the process. |
| 26 | + * no rescheduling will occur, and you will need to call dispatch again to restart the process. |
24 | 27 | * <p> |
25 | 28 | * If you wanted to create a ScheduledDataLoaderRegistry that started a rescheduling immediately, just create one and |
26 | 29 | * call {@link #rescheduleNow()}. |
@@ -94,17 +97,19 @@ public ScheduledDataLoaderRegistry unregister(String key) { |
94 | 97 | } |
95 | 98 |
|
96 | 99 | /** |
97 | | - * @return the current dispatch predicate |
| 100 | + * @return a map of data loaders to specific dispatch predicates |
98 | 101 | */ |
99 | | - public DispatchPredicate getDispatchPredicate() { |
100 | | - return dispatchPredicate; |
| 102 | + public Map<DataLoader<?, ?>, DispatchPredicate> getDataLoaderPredicates() { |
| 103 | + return new LinkedHashMap<>(dataLoaderPredicates); |
101 | 104 | } |
102 | 105 |
|
103 | 106 | /** |
104 | | - * @return a map of data loaders to specific dispatch predicates |
| 107 | + * There is a default predicate that applies to the whole {@link ScheduledDataLoaderRegistry} |
| 108 | + * |
| 109 | + * @return the default dispatch predicate |
105 | 110 | */ |
106 | | - public Map<DataLoader<?, ?>, DispatchPredicate> getDataLoaderPredicates() { |
107 | | - return new LinkedHashMap<>(dataLoaderPredicates); |
| 111 | + public DispatchPredicate getDispatchPredicate() { |
| 112 | + return dispatchPredicate; |
108 | 113 | } |
109 | 114 |
|
110 | 115 | /** |
@@ -281,7 +286,7 @@ public Builder registerAll(DataLoaderRegistry otherRegistry) { |
281 | 286 | } |
282 | 287 |
|
283 | 288 | /** |
284 | | - * This sets a predicate on the {@link DataLoaderRegistry} that will control |
| 289 | + * This sets a default predicate on the {@link DataLoaderRegistry} that will control |
285 | 290 | * whether all {@link DataLoader}s in the {@link DataLoaderRegistry }should be dispatched. |
286 | 291 | * |
287 | 292 | * @param dispatchPredicate the predicate |
|
0 commit comments