title: checking for two optionals content before calling a method
body: <p>I have a methodC() that takes two non Optional parameters both of which are wrapped and returned from other two methods called before.</p>
  
  <pre><code>Optional&lt;String&gt; s1Optional = methodA();
  Optional&lt;String&gt; s2Optional = methodB();
  </code></pre>
  
  <p>method C definition : </p>
  
  <pre><code>private Optional&lt;String&gt; methodC(String s1, String s2){
      return Optional.ofNullable("abc");
  }
  </code></pre>
  
  <p>I don't want to use s1Optional.get() and s2Optional.get() as the parameters to the methodC() as it defeats the sole purpose of using Optional.</p>
  
  <p>I know that I can use </p>
  
  <pre><code>s1Optional.map(s1 -&gt; methodC(s1, s2Optional).orElseGet(Optional.get());
  </code></pre>
  
  <p>to get a valid return from methodC() only when s1Optional is not empty, but the requirement is that I should do the same for s2Optional.
  ie, I should check for both s1Optional and s2Optional to execute methodC.</p>
  
  <p>I understand that it is not always required to use Optionals, but i was just playing around and would like to know if this is possible even.</p>