title: Optionally getting field
body: <p>I have a class structure like this:</p>
  
  <pre><code>public class Foo {
      private FooB foob;
  
      public Optional&lt;FooB&gt; getFoob() {
          return Optional.ofNullable(foob);
      }
  }
  
  public class FooB {
      private int valA;
  
      public int getValA() {
          return valA;
      }
  }
  </code></pre>
  
  <p>My objective is to call the get method for <code>fooB</code> and then check to see if it's present. If it is present then return the <code>valA</code> property, if it doesn't then just return null. So something like this:</p>
  
  <pre><code>Integer valA = foo.getFoob().ifPresent(getValA()).orElse(null);
  </code></pre>
  
  <p>Of course this isn't proper Java 8 optional syntax but that's my "psuedo code". Is there any way to achieve this in Java 8 with 1 line?</p>