How can I consume for each elements of an optional list?
<p>I have a List which can be null;</p>

<pre><code>List&lt;T&gt; list; // may or may not null
</code></pre>

<p>I want to process for each element with a consumer.</p>

<p>So far, I do.</p>

<pre><code>ofNullable(list)
        .map(List::stream)
        .ifPresent(stream -&gt; stream.forEach(e -&gt; {}));
</code></pre>

<p>or</p>

<pre><code>ofNullable(eventDataList).ifPresent(v -&gt; v.forEach(e -&gt; {}));
</code></pre>

<p>Is there any easy or concise way to do this?</p>