Skip to content

Commit

Permalink
Allow AsyncCacheLoader.bulk to be used with nullable value types, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpovirk committed Dec 5, 2024
1 parent 6ee7e20 commit 4353240
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ default CompletableFuture<? extends V> asyncReload(
* @return an asynchronous cache loader that delegates to the supplied {@code mappingFunction}
* @throws NullPointerException if the mappingFunction is null
*/
static <K, V> AsyncCacheLoader<K, V> bulk(Function<? super Set<? extends K>,
? extends Map<? extends K, ? extends V>> mappingFunction) {
static <K, V extends @Nullable Object> AsyncCacheLoader<K, V> bulk(
Function<? super Set<? extends K>, ? extends Map<? extends K, ? extends @NonNull V>>
mappingFunction) {
return CacheLoader.bulk(mappingFunction);
}

Expand All @@ -162,8 +163,12 @@ static <K, V> AsyncCacheLoader<K, V> bulk(Function<? super Set<? extends K>,
* @return an asynchronous cache loader that delegates to the supplied {@code mappingFunction}
* @throws NullPointerException if the mappingFunction is null
*/
static <K, V> AsyncCacheLoader<K, V> bulk(BiFunction<? super Set<? extends K>, ? super Executor,
? extends CompletableFuture<? extends Map<? extends K, ? extends V>>> mappingFunction) {
static <K, V extends @Nullable Object> AsyncCacheLoader<K, V> bulk(
BiFunction<
? super Set<? extends K>,
? super Executor,
? extends CompletableFuture<? extends Map<? extends K, ? extends @NonNull V>>>
mappingFunction) {
requireNonNull(mappingFunction);
return new AsyncCacheLoader<>() {
@Override public CompletableFuture<V> asyncLoad(K key, Executor executor) {
Expand Down

0 comments on commit 4353240

Please sign in to comment.