Is there a class for lazily computed values somewhere in the popular/standard Java libraries?
<p>I'm wondering whether there is a "standard" class somewhere (JDK, Guava, Apache *), that would help with the lazy initialization/computation pattern?</p>

<p>I'm thinking about something like this (let's ignore synchronization for now):</p>

<pre><code>abstract class Lazy&lt;T&gt; {
  T instance = null;
  protected T compute();
  final T get() {
    if (instance == null) instance = compute();
    return instance;
  }
}

//...

Lazy&lt;Foo&gt; foo = new Lazy&lt;Foo&gt; {
  protected Foo compute() { return Foo.expensivePart(); }
}

//...

Bar bar = foo.get().getBar();
</code></pre>
