guava/src/com/google/common/base/Suppliers.java
public static <T> Supplier<T> memoize(Supplier<T> delegate) {
    if (delegate instanceof NonSerializableMemoizingSupplier
        || delegate instanceof MemoizingSupplier) {
      return delegate;
    }
    return delegate instanceof Serializable
        ? new MemoizingSupplier<T>(delegate)
        : new NonSerializableMemoizingSupplier<T>(delegate);
  }
public static <T> Supplier<T> memoize(Supplier<T> delegate) {
    if (delegate instanceof NonSerializableMemoizingSupplier
        || delegate instanceof MemoizingSupplier) {
      return delegate;
    }
    return delegate instanceof Serializable
        ? new MemoizingSupplier<T>(delegate)
        : new NonSerializableMemoizingSupplier<T>(delegate);
  }
Returns a supplier which caches the instance retrieved during the first call to {@code get()}
and returns that value on subsequent calls to {@code get()}. See: <a
href="http://en.wikipedia.org/wiki/Memoization">memoization</a>

<p>The returned supplier is thread-safe. The delegate's {@code get()} method will be invoked at
most once unless the underlying {@code get()} throws an exception. The supplier's serialized
form does not contain the cached value, which will be recalculated when {@code get()} is called
on the reserialized instance.

<p>When the underlying delegate throws an exception then this memoizing supplier will keep
delegating calls until it returns valid data.

<p>If {@code delegate} is an instance created by an earlier call to {@code memoize}, it is
returned directly.