title: How to check if is null and if has a specific value using Optional in java?
body: <p>Assume that I have this code in my project:</p>
  
  <pre><code>public List&lt;T&gt; getAll(Integer parameter) {
      if(parameter != null &amp;&amp; parameter &gt; -1) {
          // do something here
      }
  }
  </code></pre>
  
  <p>My question is: how can I do the checking with <code>Optional</code> instead of using <code>if</code>, or if there is another thing I could use?</p>