Skip to content

Commit 533065b

Browse files
committed
Breaking change - renaming old mutable setXX methods and going to builder pattern only
1 parent 4569c43 commit 533065b

15 files changed

+186
-253
lines changed

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ for the context object.
205205

206206
```java
207207
DataLoaderOptions options = DataLoaderOptions.newOptions()
208-
.withBatchLoaderContextProvider(() -> SecurityCtx.getCallingUserCtx());
208+
.setBatchLoaderContextProvider(() -> SecurityCtx.getCallingUserCtx()).build();
209209

210210
BatchLoaderWithContext<String, String> batchLoader = new BatchLoaderWithContext<String, String>() {
211211
@Override
@@ -227,7 +227,7 @@ You can gain access to them as a map by key or as the original list of context o
227227

228228
```java
229229
DataLoaderOptions options = DataLoaderOptions.newOptions()
230-
.withBatchLoaderContextProvider(() -> SecurityCtx.getCallingUserCtx());
230+
.setBatchLoaderContextProvider(() -> SecurityCtx.getCallingUserCtx()).build();
231231

232232
BatchLoaderWithContext<String, String> batchLoader = new BatchLoaderWithContext<String, String>() {
233233
@Override
@@ -433,7 +433,7 @@ However, you can create your own custom future cache and supply it to the data l
433433

434434
```java
435435
MyCustomCache customCache = new MyCustomCache();
436-
DataLoaderOptions options = DataLoaderOptions.newOptions().withsetCacheMap(customCache);
436+
DataLoaderOptions options = DataLoaderOptions.newOptions().setCacheMap(customCache).build();
437437
DataLoaderFactory.newDataLoader(userBatchLoader, options);
438438
```
439439

@@ -467,7 +467,7 @@ The tests have an example based on [Caffeine](https://github.com/ben-manes/caffe
467467
In certain uncommon cases, a DataLoader which does not cache may be desirable.
468468

469469
```java
470-
DataLoaderFactory.newDataLoader(userBatchLoader, DataLoaderOptions.newOptions().withCachingEnabled(false));
470+
DataLoaderFactory.newDataLoader(userBatchLoader, DataLoaderOptions.newOptions().setCachingEnabled(false).build());
471471
```
472472

473473
Calling the above will ensure that every call to `.load()` will produce a new promise, and requested keys will not be saved in memory.
@@ -533,7 +533,7 @@ Knowing what the behaviour of your data is important for you to understand how e
533533
You can configure the statistics collector used when you build the data loader
534534

535535
```java
536-
DataLoaderOptions options = DataLoaderOptions.newOptions().withStatisticsCollector(() -> new ThreadLocalStatisticsCollector());
536+
DataLoaderOptions options = DataLoaderOptions.newOptions().setStatisticsCollector(() -> new ThreadLocalStatisticsCollector()).build();
537537
DataLoader<String,User> userDataLoader = DataLoaderFactory.newDataLoader(userBatchLoader,options);
538538

539539
```
@@ -780,7 +780,7 @@ You set the `DataLoaderInstrumentation` into the `DataLoaderOptions` at build ti
780780
});
781781
}
782782
};
783-
DataLoaderOptions options = DataLoaderOptions.newOptions().withInstrumentation(timingInstrumentation);
783+
DataLoaderOptions options = DataLoaderOptions.newOptions().setInstrumentation(timingInstrumentation).build();
784784
DataLoader<String, User> userDataLoader = DataLoaderFactory.newDataLoader(userBatchLoader, options);
785785

786786
```

src/main/java/org/dataloader/DataLoaderFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ public static <K, V> Builder<K, V> builder(DataLoader<K, V> dataLoader) {
542542
*/
543543
public static class Builder<K, V> {
544544
Object batchLoadFunction;
545-
DataLoaderOptions options = DataLoaderOptions.newOptions();
545+
DataLoaderOptions options = DataLoaderOptions.newDefaultOptions();
546546

547547
Builder() {
548548
}

0 commit comments

Comments
 (0)