Java 8 map collection and add a default value if the collection is empty
<p>I've got a use case where I must return a collection with at least 1 element. The incoming collection may have 0 or more elements. </p>

<p>so this could be done fairly easily</p>

<pre><code>Set&lt;ObjectB&gt; setOfB = collectionOfA.isEmpty() ? 
        new HashSet&lt;ObjectB&gt;() {{ add(new ObjectB()); }}  : 
        collectionOfA
           .stream()
           .map(item -&gt; new ObjectB(item))
           .collect(Collectors.toSet()); 
</code></pre>

<p>BUT.... </p>

<p>I'm also trying to use this as a chance to better familiarize myself with the Java 8 tools and features, and so i'm trying to see if this can be done without the conditional test and in a more Java 8-like way. </p>

<p>Thoughts and suggestions are most appreciated!</p>