-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathWith.java
More file actions
36 lines (28 loc) · 994 Bytes
/
With.java
File metadata and controls
36 lines (28 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package org.dataloader.orchestration;
import org.dataloader.DataLoader;
import java.util.function.Function;
import static org.dataloader.orchestration.Orchestrator.castAs;
import static org.dataloader.orchestration.Step.loadImpl;
/**
* A transitional step that allows a new step to be started with a new data loader in play
*
* @param <K> the key type
* @param <V> the value type
*/
public class With<K, V> {
private final Orchestrator<?, ?> orchestrator;
private final DataLoader<K, V> dl;
public With(Orchestrator<?, ?> orchestrator, DataLoader<K, V> dl) {
this.orchestrator = orchestrator;
this.dl = dl;
}
public Step<K, V> load(K key) {
return load(key, null);
}
public Step<K, V> load(K key, Object keyContext) {
return loadImpl(orchestrator, castAs(dl), key,keyContext);
}
public Step<V, V> thenLoad(Function<V, K> codeToRun) {
return Step.thenLoadImpl(orchestrator, castAs(dl), codeToRun);
}
}