@Test public void shouldMemoizeSuppliedValue() { final ConcurrentMap<String, Boolean> cache = new ConcurrentHashMap<>(); final Supplier<String> keySupplier = () -> "key"; final BooleanSupplier supplier = () -> true; final ConcurrentMapBasedBooleanSupplierMemoizer<String> memoizer = new ConcurrentMapBasedBooleanSupplierMemoizer<>( cache, keySupplier, supplier); Assert.assertTrue("Memoized value does not match expectations", memoizer.getAsBoolean()); }
@Override public boolean getAsBoolean() { return computeIfAbsent(keySupplier.get(), input -> Boolean.valueOf(supplier.getAsBoolean())).booleanValue(); }
ConcurrentMapBasedBooleanSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Boolean> implements BooleanSupplier { @Override public boolean getAsBoolean() { return computeIfAbsent(keySupplier.get(), input -> Boolean.valueOf(supplier.getAsBoolean())).booleanValue(); } }
ConcurrentMapBasedBooleanSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Boolean> implements BooleanSupplier { @Override public boolean getAsBoolean() { return computeIfAbsent(keySupplier.get(), input -> Boolean.valueOf(supplier.getAsBoolean())).booleanValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedBooleanSupplierMemoizer(
            final ConcurrentMap<KEY, Boolean> cache,
            final Supplier<KEY> keySupplier,
            final BooleanSupplier supplier); }
ConcurrentMapBasedBooleanSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Boolean> implements BooleanSupplier { @Override public boolean getAsBoolean() { return computeIfAbsent(keySupplier.get(), input -> Boolean.valueOf(supplier.getAsBoolean())).booleanValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedBooleanSupplierMemoizer(
            final ConcurrentMap<KEY, Boolean> cache,
            final Supplier<KEY> keySupplier,
            final BooleanSupplier supplier); @Override boolean getAsBoolean(); }
ConcurrentMapBasedBooleanSupplierMemoizer extends ConcurrentMapBasedMemoizer<KEY, Boolean> implements BooleanSupplier { @Override public boolean getAsBoolean() { return computeIfAbsent(keySupplier.get(), input -> Boolean.valueOf(supplier.getAsBoolean())).booleanValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedBooleanSupplierMemoizer(
            final ConcurrentMap<KEY, Boolean> cache,
            final Supplier<KEY> keySupplier,
            final BooleanSupplier supplier); @Override boolean getAsBoolean();  }