title: Java 8 generic collections with optionals
body: <p>I have a relatively simple looking problem that I am trying to solve. There doesn't seem to be an intuitive way to do this or, I am missing something here.</p>
  
  <p>Consider this method to find the main image and if none exists, return first image-</p>
  
  <pre><code>public Image findMainImage(Collection&lt;? extends Image&gt; images) {
      if (images == null || images.isEmpty()) return null
      return images.stream()
                   .filter(Image::isMain)
                   .findFirst()
                   .orElse(images.iterator().next())
  }
  </code></pre>
  
  <p>I get an error - <code>orElse(capture&lt;? extends Image&gt;) in Optional cannot be applied</code></p>
  
  <p>Any direction on this would be great.</p>