-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathDelegatingDataLoaderFactory.java
More file actions
71 lines (57 loc) · 2.64 KB
/
DelegatingDataLoaderFactory.java
File metadata and controls
71 lines (57 loc) · 2.64 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.dataloader.fixtures.parameterized;
import org.dataloader.DataLoader;
import org.dataloader.DataLoaderOptions;
import org.dataloader.DelegatingDataLoader;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class DelegatingDataLoaderFactory implements TestDataLoaderFactory {
// its delegates all the way down to the turtles
private final TestDataLoaderFactory delegateFactory;
public DelegatingDataLoaderFactory(TestDataLoaderFactory delegateFactory) {
this.delegateFactory = delegateFactory;
}
@Override
public String toString() {
return "DelegatingDataLoaderFactory{" +
"delegateFactory=" + delegateFactory +
'}';
}
@Override
public TestDataLoaderFactory unwrap() {
return delegateFactory.unwrap();
}
private <K, V> DataLoader<K, V> mkDelegateDataLoader(DataLoader<K, V> dataLoader) {
return new DelegatingDataLoader<>(dataLoader);
}
@Override
public <K> DataLoader<K, K> idLoader(DataLoaderOptions options, List<Collection<K>> loadCalls) {
return mkDelegateDataLoader(delegateFactory.idLoader(options, loadCalls));
}
@Override
public <K> DataLoader<K, K> idLoaderDelayed(DataLoaderOptions options, List<Collection<K>> loadCalls, Duration delay) {
return mkDelegateDataLoader(delegateFactory.idLoaderDelayed(options, loadCalls, delay));
}
@Override
public <K> DataLoader<K, K> idLoaderBlowsUps(
DataLoaderOptions options, List<Collection<K>> loadCalls) {
return mkDelegateDataLoader(delegateFactory.idLoaderBlowsUps(options, loadCalls));
}
@Override
public <K> DataLoader<K, Object> idLoaderAllExceptions(DataLoaderOptions options, List<Collection<K>> loadCalls) {
return mkDelegateDataLoader(delegateFactory.idLoaderAllExceptions(options, loadCalls));
}
@Override
public DataLoader<Integer, Object> idLoaderOddEvenExceptions(DataLoaderOptions options, List<Collection<Integer>> loadCalls) {
return mkDelegateDataLoader(delegateFactory.idLoaderOddEvenExceptions(options, loadCalls));
}
@Override
public DataLoader<String, String> onlyReturnsNValues(int N, DataLoaderOptions options, ArrayList<Object> loadCalls) {
return mkDelegateDataLoader(delegateFactory.onlyReturnsNValues(N, options, loadCalls));
}
@Override
public DataLoader<String, String> idLoaderReturnsTooMany(int howManyMore, DataLoaderOptions options, ArrayList<Object> loadCalls) {
return mkDelegateDataLoader(delegateFactory.idLoaderReturnsTooMany(howManyMore, options, loadCalls));
}
}