Skip to content

Commit 3099f1a

Browse files
committed
Adds a predicate to ScheduledDataLoaderRegistry - improved doco
1 parent 69528f1 commit 3099f1a

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/main/java/org/dataloader/registries/ScheduledDataLoaderRegistry.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
import static org.dataloader.impl.Assertions.nonNull;
1616

1717
/**
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
1919
* to test (for each {@link DataLoader} in the registry) if a dispatch should proceed. If the predicate returns false, then a task is scheduled
2020
* to perform that predicate dispatch again via the {@link ScheduledExecutorService}.
2121
* <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>
2225
* 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.
2427
* <p>
2528
* If you wanted to create a ScheduledDataLoaderRegistry that started a rescheduling immediately, just create one and
2629
* call {@link #rescheduleNow()}.
@@ -94,17 +97,19 @@ public ScheduledDataLoaderRegistry unregister(String key) {
9497
}
9598

9699
/**
97-
* @return the current dispatch predicate
100+
* @return a map of data loaders to specific dispatch predicates
98101
*/
99-
public DispatchPredicate getDispatchPredicate() {
100-
return dispatchPredicate;
102+
public Map<DataLoader<?, ?>, DispatchPredicate> getDataLoaderPredicates() {
103+
return new LinkedHashMap<>(dataLoaderPredicates);
101104
}
102105

103106
/**
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
105110
*/
106-
public Map<DataLoader<?, ?>, DispatchPredicate> getDataLoaderPredicates() {
107-
return new LinkedHashMap<>(dataLoaderPredicates);
111+
public DispatchPredicate getDispatchPredicate() {
112+
return dispatchPredicate;
108113
}
109114

110115
/**
@@ -281,7 +286,7 @@ public Builder registerAll(DataLoaderRegistry otherRegistry) {
281286
}
282287

283288
/**
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
285290
* whether all {@link DataLoader}s in the {@link DataLoaderRegistry }should be dispatched.
286291
*
287292
* @param dispatchPredicate the predicate

0 commit comments

Comments
 (0)