fix #146
[memoization.java.git] / memoization-jcache / src / main / java / de / xn__ho_hia / memoization / jcache / JCacheBasedLongSupplierMemoizer.java
blob53e0e29b1066f34a33014fa4a5d13c13753e15bf
1 /*
2 * This file is part of memoization.java. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of memoization.java,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
5 * in the LICENSE file.
6 */
7 package de.xn__ho_hia.memoization.jcache;
9 import java.util.function.LongSupplier;
10 import java.util.function.Supplier;
12 import javax.cache.Cache;
14 final class JCacheBasedLongSupplierMemoizer<KEY>
15 extends AbstractJCacheBasedMemoizer<KEY, Long>
16 implements LongSupplier {
18 private final Supplier<KEY> keySupplier;
19 private final LongSupplier supplier;
21 JCacheBasedLongSupplierMemoizer(
22 final Cache<KEY, Long> cache,
23 final Supplier<KEY> keySupplier,
24 final LongSupplier supplier) {
25 super(cache);
26 this.keySupplier = keySupplier;
27 this.supplier = supplier;
30 @Override
31 public long getAsLong() {
32 return invoke(keySupplier.get(), key -> Long.valueOf(supplier.getAsLong())).longValue();