title: Java 8 Lambda Replacement for Apache Commons CollectionsUtils.select
body: <p>I have the following code using Apache Commons lib:</p>
  
  <pre><code>public static List&lt;Address&gt; addressesHasType(final List&lt;Address&gt; addresses, final AddressType... types) {
      return (List&lt;Address&gt;) CollectionUtils.select(addresses, new Predicate() {
          @Override
          public boolean evaluate(final Object object) {
              boolean isContains = false;
              for (int i = 0; i &lt; types.length &amp;&amp; !isContains; i++) {
                  isContains = ((Address) object).getTypes().contains(types[i]);
              }
              return isContains;
          }
      });
  }
  </code></pre>
  
  <p>I trying to make to refactor it to use only lambda and Java 8 without Apache Commons lib, something like this:</p>
  
  <pre><code>List&lt;Address&gt; addressList = addresses.stream()
      .filter(a -&gt; a.getTypes().contains(types)).collect(Collectors.toList());
  </code></pre>
  
  <p>But the list become empty in the end. I tried using findFirst() to but it does not returns a List but a Optional object. </p>
  
  <pre><code>addressList2 = addresses.stream()
      .filter(a -&gt; a.getTypes().contains(types)).findFirst();
  </code></pre>
  
  <p>How I can do this?</p>