JCacheBasedLongSupplierMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements LongSupplier { @Override public long getAsLong() { return invoke(keySupplier.get(), key -> Long.valueOf(supplier.getAsLong())).longValue(); } JCacheBasedLongSupplierMemoizer(
            final Cache<KEY, Long> cache,
            final Supplier<KEY> keySupplier,
            final LongSupplier supplier); @Override long getAsLong();  }
@Test public void shouldMemoizeSupplier() { final LongSupplier supplier = () -> 123; final Supplier<String> keySupplier = () -> "key"; try (final Cache<String, Long> cache = JCacheMemoize.createCache(Supplier.class)) { final JCacheBasedLongSupplierMemoizer<String> loader = new JCacheBasedLongSupplierMemoizer<>(cache, keySupplier, supplier); Assert.assertEquals("Memoized value does not match expectation", 123L, loader.getAsLong()); } }