1- /*
2- * Copyright (c) 2016 The original author or authors
3- *
4- * All rights reserved. This program and the accompanying materials
5- * are made available under the terms of the Eclipse Public License v1.0
6- * and Apache License v2.0 which accompanies this distribution.
7- *
8- * The Eclipse Public License is available at
9- * http://www.eclipse.org/legal/epl-v10.html
10- *
11- * The Apache License v2.0 is available at
12- * http://www.opensource.org/licenses/apache2.0.php
13- *
14- * You may elect to redistribute this code under either of these licenses.
15- */
16-
171package org .dataloader ;
182
193import org .dataloader .annotations .PublicApi ;
226import org .dataloader .scheduler .BatchLoaderScheduler ;
237import org .dataloader .stats .NoOpStatisticsCollector ;
248import org .dataloader .stats .StatisticsCollector ;
9+ import org .jspecify .annotations .NullMarked ;
10+ import org .jspecify .annotations .Nullable ;
2511
2612import java .util .Objects ;
2713import java .util .Optional ;
3723 * @author <a href="https://github.com/aschrijver/">Arnold Schrijver</a>
3824 */
3925@ PublicApi
26+ @ NullMarked
4027public class DataLoaderOptions {
4128
4229 private static final BatchLoaderContextProvider NULL_PROVIDER = () -> null ;
@@ -46,14 +33,14 @@ public class DataLoaderOptions {
4633 private final boolean batchingEnabled ;
4734 private final boolean cachingEnabled ;
4835 private final boolean cachingExceptionsEnabled ;
49- private final CacheKey <?> cacheKeyFunction ;
50- private final CacheMap <?, ?> cacheMap ;
51- private final ValueCache <?, ?> valueCache ;
36+ private final @ Nullable CacheKey <?> cacheKeyFunction ;
37+ private final @ Nullable CacheMap <?, ?> cacheMap ;
38+ private final @ Nullable ValueCache <?, ?> valueCache ;
5239 private final int maxBatchSize ;
5340 private final Supplier <StatisticsCollector > statisticsCollector ;
5441 private final BatchLoaderContextProvider environmentProvider ;
5542 private final ValueCacheOptions valueCacheOptions ;
56- private final BatchLoaderScheduler batchLoaderScheduler ;
43+ private final @ Nullable BatchLoaderScheduler batchLoaderScheduler ;
5744 private final DataLoaderInstrumentation instrumentation ;
5845
5946 /**
@@ -243,7 +230,7 @@ public ValueCacheOptions getValueCacheOptions() {
243230 /**
244231 * @return the {@link BatchLoaderScheduler} to use, which can be null
245232 */
246- public BatchLoaderScheduler getBatchLoaderScheduler () {
233+ public @ Nullable BatchLoaderScheduler getBatchLoaderScheduler () {
247234 return batchLoaderScheduler ;
248235 }
249236
@@ -258,14 +245,14 @@ public static class Builder {
258245 private boolean batchingEnabled ;
259246 private boolean cachingEnabled ;
260247 private boolean cachingExceptionsEnabled ;
261- private CacheKey <?> cacheKeyFunction ;
262- private CacheMap <?, ?> cacheMap ;
263- private ValueCache <?, ?> valueCache ;
248+ private @ Nullable CacheKey <?> cacheKeyFunction ;
249+ private @ Nullable CacheMap <?, ?> cacheMap ;
250+ private @ Nullable ValueCache <?, ?> valueCache ;
264251 private int maxBatchSize ;
265252 private Supplier <StatisticsCollector > statisticsCollector ;
266253 private BatchLoaderContextProvider environmentProvider ;
267254 private ValueCacheOptions valueCacheOptions ;
268- private BatchLoaderScheduler batchLoaderScheduler ;
255+ private @ Nullable BatchLoaderScheduler batchLoaderScheduler ;
269256 private DataLoaderInstrumentation instrumentation ;
270257
271258 public Builder () {
@@ -326,7 +313,7 @@ public Builder setCachingExceptionsEnabled(boolean cachingExceptionsEnabled) {
326313 * @param cacheKeyFunction the cache key function to use
327314 * @return this builder for fluent coding
328315 */
329- public Builder setCacheKeyFunction (CacheKey <?> cacheKeyFunction ) {
316+ public Builder setCacheKeyFunction (@ Nullable CacheKey <?> cacheKeyFunction ) {
330317 this .cacheKeyFunction = cacheKeyFunction ;
331318 return this ;
332319 }
@@ -337,7 +324,7 @@ public Builder setCacheKeyFunction(CacheKey<?> cacheKeyFunction) {
337324 * @param cacheMap the cache map instance
338325 * @return this builder for fluent coding
339326 */
340- public Builder setCacheMap (CacheMap <?, ?> cacheMap ) {
327+ public Builder setCacheMap (@ Nullable CacheMap <?, ?> cacheMap ) {
341328 this .cacheMap = cacheMap ;
342329 return this ;
343330 }
@@ -348,7 +335,7 @@ public Builder setCacheMap(CacheMap<?, ?> cacheMap) {
348335 * @param valueCache the value cache instance
349336 * @return this builder for fluent coding
350337 */
351- public Builder setValueCache (ValueCache <?, ?> valueCache ) {
338+ public Builder setValueCache (@ Nullable ValueCache <?, ?> valueCache ) {
352339 this .valueCache = valueCache ;
353340 return this ;
354341 }
@@ -407,7 +394,7 @@ public Builder setValueCacheOptions(ValueCacheOptions valueCacheOptions) {
407394 * @param batchLoaderScheduler the scheduler
408395 * @return this builder for fluent coding
409396 */
410- public Builder setBatchLoaderScheduler (BatchLoaderScheduler batchLoaderScheduler ) {
397+ public Builder setBatchLoaderScheduler (@ Nullable BatchLoaderScheduler batchLoaderScheduler ) {
411398 this .batchLoaderScheduler = batchLoaderScheduler ;
412399 return this ;
413400 }
0 commit comments