24
24
import scala .collection .mutable .ArrayBuffer ;
25
25
import scala .compat .java8 .FutureConverters ;
26
26
import scala .concurrent .Future ;
27
+ import scala .concurrent .ExecutionContext ;
27
28
28
29
import java .util .ArrayList ;
29
30
import java .util .List ;
@@ -35,15 +36,83 @@ public class JavaFetcher {
35
36
Fetcher fetcher ;
36
37
37
38
public JavaFetcher (KVStore kvStore , String metaDataSet , Long timeoutMillis , Consumer <LoggableResponse > logFunc , ExternalSourceRegistry registry , String callerName , Boolean disableErrorThrows ) {
38
- this .fetcher = new Fetcher (kvStore , metaDataSet , timeoutMillis , logFunc , false , registry , callerName , null , disableErrorThrows );
39
+ this .fetcher = new Fetcher (kvStore , metaDataSet , timeoutMillis , logFunc , false , registry , callerName , null , disableErrorThrows , null );
39
40
}
40
41
41
42
public JavaFetcher (KVStore kvStore , String metaDataSet , Long timeoutMillis , Consumer <LoggableResponse > logFunc , ExternalSourceRegistry registry ) {
42
- this .fetcher = new Fetcher (kvStore , metaDataSet , timeoutMillis , logFunc , false , registry , null , null , false );
43
+ this .fetcher = new Fetcher (kvStore , metaDataSet , timeoutMillis , logFunc , false , registry , null , null , false , null );
43
44
}
44
45
45
46
public JavaFetcher (KVStore kvStore , String metaDataSet , Long timeoutMillis , Consumer <LoggableResponse > logFunc , ExternalSourceRegistry registry , String callerName , FlagStore flagStore , Boolean disableErrorThrows ) {
46
- this .fetcher = new Fetcher (kvStore , metaDataSet , timeoutMillis , logFunc , false , registry , callerName , flagStore , disableErrorThrows );
47
+ this .fetcher = new Fetcher (kvStore , metaDataSet , timeoutMillis , logFunc , false , registry , callerName , flagStore , disableErrorThrows , null );
48
+ }
49
+
50
+ /* user builder pattern to create JavaFetcher
51
+ example way to create the java fetcher
52
+ JavaFetcher fetcher = new JavaFetcher.Builder(kvStore, metaDataSet, timeoutMillis, logFunc, registry)
53
+ .callerName(callerName)
54
+ .flagStore(flagStore)
55
+ .disableErrorThrows(disableErrorThrows)
56
+ .build();
57
+ */
58
+ private JavaFetcher (Builder builder ) {
59
+ this .fetcher = new Fetcher (builder .kvStore ,
60
+ builder .metaDataSet ,
61
+ builder .timeoutMillis ,
62
+ builder .logFunc ,
63
+ builder .debug ,
64
+ builder .registry ,
65
+ builder .callerName ,
66
+ builder .flagStore ,
67
+ builder .disableErrorThrows ,
68
+ builder .executionContextOverride );
69
+ }
70
+
71
+ public static class Builder {
72
+ private KVStore kvStore ;
73
+ private String metaDataSet ;
74
+ private Long timeoutMillis ;
75
+ private Consumer <LoggableResponse > logFunc ;
76
+ private ExternalSourceRegistry registry ;
77
+ private String callerName ;
78
+ private Boolean debug ;
79
+ private FlagStore flagStore ;
80
+ private Boolean disableErrorThrows ;
81
+ private ExecutionContext executionContextOverride ;
82
+
83
+ public Builder (KVStore kvStore , String metaDataSet , Long timeoutMillis ,
84
+ Consumer <LoggableResponse > logFunc , ExternalSourceRegistry registry ) {
85
+ this .kvStore = kvStore ;
86
+ this .metaDataSet = metaDataSet ;
87
+ this .timeoutMillis = timeoutMillis ;
88
+ this .logFunc = logFunc ;
89
+ this .registry = registry ;
90
+ }
91
+ public Builder callerName (String callerName ) {
92
+ this .callerName = callerName ;
93
+ return this ;
94
+ }
95
+ public Builder flagStore (FlagStore flagStore ) {
96
+ this .flagStore = flagStore ;
97
+ return this ;
98
+ }
99
+ public Builder disableErrorThrows (Boolean disableErrorThrows ) {
100
+ this .disableErrorThrows = disableErrorThrows ;
101
+ return this ;
102
+ }
103
+ public Builder debug (Boolean debug ) {
104
+ this .debug = debug ;
105
+ return this ;
106
+ }
107
+
108
+ public Builder executionContextOverride (ExecutionContext executionContextOverride ) {
109
+ this .executionContextOverride = executionContextOverride ;
110
+ return this ;
111
+ }
112
+
113
+ public JavaFetcher build () {
114
+ return new JavaFetcher (this );
115
+ }
47
116
}
48
117
49
118
0 commit comments