### Question:
Suppliers { public static <T> Supplier<T> memoize(Supplier<T> delegate) { AtomicReference<T> value = new AtomicReference<>(); return () -> { T val = value.get(); if (val == null) { val = value.updateAndGet(cur -> cur == null ? Objects.requireNonNull(delegate.get()) : cur); } return val; }; } private  Suppliers(); static Supplier<T> memoize(Supplier<T> delegate);  }### Answer:
@Test public void memoize() { AtomicInteger calledTimes = new AtomicInteger(); Supplier<String> delegate = () -> { calledTimes.incrementAndGet(); return "The value"; }; Supplier<String> memoize = Suppliers.memoize(delegate); Assertions.assertEquals(0, calledTimes.get()); memoize.get(); Assertions.assertEquals(1, calledTimes.get()); memoize.get(); memoize.get(); Assertions.assertEquals(1, calledTimes.get()); memoize.get(); memoize.get(); memoize.get(); Assertions.assertEquals(1, calledTimes.get()); }