title: Optional Map typecasting to child class object
body: <p>I am trying to write following code where <code>C</code> is a child class of <code>B</code>. And getValue method only available in <code>C</code>, not in <code>B</code>. But Eclipse is showing an error in this statement:</p>
  
  <pre><code>Optional.ofNullable(A).map(A::getB).map(C::getValue);
  </code></pre>
  
  <p>If it is normal case, we will type cast and write like <code>((C)a.getB()).getValue()</code>. How do I write same in terms of an <code>Optional</code>? </p>