@Test public void shouldMemoizeSuppliedValue() { final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>(); final Supplier<String> keySupplier = () -> "key"; final LongSupplier supplier = () -> 123L; final ConcurrentMapBasedLongSupplierMemoizer<String> memoizer = new ConcurrentMapBasedLongSupplierMemoizer<>( cache, keySupplier, supplier); Assert.assertEquals("Memoized value does not match expectations", 123L, memoizer.getAsLong()); }
@Override public long getAsLong() { return computeIfAbsent(keySupplier.get(), input -> Long.valueOf(supplier.getAsLong())).longValue(); }
ConcurrentMapBasedLongSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongSupplier { @Override public long getAsLong() { return computeIfAbsent(keySupplier.get(), input -> Long.valueOf(supplier.getAsLong())).longValue(); } }
ConcurrentMapBasedLongSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongSupplier { @Override public long getAsLong() { return computeIfAbsent(keySupplier.get(), input -> Long.valueOf(supplier.getAsLong())).longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongSupplierMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final Supplier<KEY> keySupplier,
            final LongSupplier supplier); }
ConcurrentMapBasedLongSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongSupplier { @Override public long getAsLong() { return computeIfAbsent(keySupplier.get(), input -> Long.valueOf(supplier.getAsLong())).longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongSupplierMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final Supplier<KEY> keySupplier,
            final LongSupplier supplier); @Override long getAsLong(); }
ConcurrentMapBasedLongSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongSupplier { @Override public long getAsLong() { return computeIfAbsent(keySupplier.get(), input -> Long.valueOf(supplier.getAsLong())).longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongSupplierMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final Supplier<KEY> keySupplier,
            final LongSupplier supplier); @Override long getAsLong();  }