Class Once<T>

java.lang.Object
microsim.caching.Once<T>
All Implemented Interfaces:
Supplier<T>

public class Once<T> extends Object implements Supplier<T>

Cache the result of a Supplier so that it is only called once.

This requires the wrapped Supplier to return a non-null object. This is lazy in the sense that the wrapped Supplier is only called when the value is requested for the first time.

  • Constructor Details

    • Once

      public Once(Supplier<? extends T> supplier)

      Build a cache wrapping the given Supplier.

      Note that wrapping a Once automatically flattens it.

  • Method Details