title: Stream Way to get index of first element matching boolean
body: <p>I have a <code>List&lt;Users&gt;</code>. I want to get the index of the (first) user in the stream with a particular username. I don't want to actually require the <code>User</code> to be <code>.equals()</code> to some described <code>User</code>, just to have the same username. </p>
  
  <p>I can think of ugly ways to do this (iterate and count), but it feels like there should be a nice way to do this, probably by using Streams. So far the best I have is:</p>
  
  <pre><code>int index = users.stream()
      .map(user -&gt; user.getName())
      .collect(Collectors.toList())
      .indexOf(username);
  </code></pre>
  
  <p>Which isn't the worst code I've ever written, but it's not great. It's also not that flexible, as it relies on there being a mapping function to a type with a <code>.equals()</code> function that describes the property you're looking for; I'd much rather have something that could work for arbitrary <code>Function&lt;T, Boolean&gt;</code></p>
  
  <p>Anyone know how?</p>