title: Is there an idiomatic way to assert a stream has only one element while yielding that element?
body: <p>Starting with this code:</p>
  <pre><code>public Thing thereCanBeOnlyOne(Stream&lt;Thing&gt; stream) {
    List&lt;Thing&gt; things = stream.collect(Collectors.toList());  
    if(things.size() != 1) {
      throw new IllegalArgumentException();
    }
    return things.get(0);
  }
  </code></pre>
  <p>Is there a more succint way to express the method body?</p>
  <p>What I tried so far:</p>
  <p>I read the documentation for <code>Collector</code> and <code>reduce</code>, but didn't find anything.</p>