title: How to filter Optional.empty in java 8
body: <p>I want to filter the values with 0 to print message invalid but I get Optional.empty as result</p>
  
  <pre><code> Long l = 0L;
   Optional&lt;String&gt; l2 = Optional.of(l).filter(t -&gt; t&gt;0).map(t -&gt;t.toString());
   Optional&lt;String&gt;l3 =l2.filter(String::isEmpty).map(t -&gt;"invalid");
   System.out.println(l3);
  </code></pre>
  
  <p>Need return type to be <code>Optional&lt;String&gt;</code></p>
  
  <p>Expected output - <code>Invalid</code><br>
  Actual Output - <code>Optional.empty</code></p>
  
  <p><strong>Updated</strong></p>
  
  <p>Need return type to be <code>String</code></p>
  
  <p>Expected output - <code>Invalid value 0</code><br>
  Actual Output - <code>Optional.empty</code></p>