title: Lazy non-modifiable list in Google Collections
body: <p>I was looking for a decent implementation of a generic lazy non-modifiable list implementation to wrap my search result entries. The unmodifiable part of the task is easy as it can be achieved by <code>Collections.unmodifiableList()</code> so I only need to sort out the the lazy part.</p>
  
  <p>Surprisingly, <a href="http://code.google.com/p/google-collections/" rel="nofollow noreferrer">google-collections</a> doesn't have anything to offer; while <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/list/LazyList.html" rel="nofollow noreferrer">LazyList from Apache Commons Collections</a> does not support generics.</p>
  
  <p>I have found <a href="http://log4p.com/2007/10/01/lazylist-based-on-the-google-collections-library/" rel="nofollow noreferrer">an attempt</a> to build something on top of google-collections but it seems to be incomplete (e.g. does not support <code>size()</code>), outdated (does not compile with 1.0 final) and requiring some external classes, but could be used as a good starting point to build my own class.</p>
  
  <p>Is anybody aware of any good implementation of a LazyList? If not, which option do you think is better:</p>
  
  <ul>
  <li>write my own implementation, based on google-collections ForwardingList, similar to what Peter Maas did;</li>
  <li>write my own wrapper around Commons Collections LazyList (the wrapper would only add generics so I don't have to cast everywhere but only in the wrapper itself);</li>
  <li>just write something on top of <code>java.util.AbstractList</code>;</li>
  </ul>
  
  <p>Any other suggestions are welcome.</p>
  
  <p>EDIT: explanation why I need a lazy list.</p>
  
  <p>I have got a Lucene search result (TopDocs) which is basically a bunch of pointers to Lucene documents. My search result class would take these pointers as an input and return a list of objects which are made of extracted and otherwise processed Lucene documents. By wrapping everything into a lazy list I want to ensure I am not doing expensive processing when unnecessary.</p>