title: Optional type and Spring Data Rest Projections
body: <p>I've got a couple of classes like the following where a <code>Person</code> has an <code>Optional</code> <code>Employer</code>.</p>
  
  <pre class="lang-java prettyprint-override"><code>    class Person {
          String getFirstName() {...}
          String getLastName() {...}
          Optional&lt;Employer&gt; getEmployer() {...}
      }
  
      class Employer {
         String getName() {...}
         String getAddress() {...}
      }
  </code></pre>
  
  <p>Using Spring Data Rest, I'd like to apply a projection to <code>Person</code> that also includes a projection of <code>Employer</code>.  Something like this.</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Projection(name="simple", types=Person.class)
      interface PersonProjection {
         String getFirstName();
         Optional&lt;EmployerProjection&gt; getEmployer();
      }
  
      @Projection(name="employer", types=Employer.class)
      interface EmployerProjection {
         String getName();
      }
  </code></pre>
  
  <p>However, what I'm seeing is that the <code>EmployerProjection</code> isn't getting used.  The <code>PersonProjection</code> is working, but it's behaving as if <code>PersonProjection</code> were defined like this. </p>
  
  <pre class="lang-java prettyprint-override"><code>    @Projection(name="simple", types=Person.class)
      interface PersonProjection {
         String getFirstName();
         Optional&lt;Employer&gt; getEmployer();
      }
  </code></pre>
  
  <p><code>EmployerProjection</code> is being ignored.  There seems to be something about the <code>Optional</code> part that's causing the problem.  If I change the return type of <code>getEmployer()</code> on both the Person class and PersonProjection to be <code>Employer</code> instead of <code>Optional&lt;Employer&gt;</code>, the <code>EmployerProjection</code> is picked up and it works.  Either <code>Optional</code> isn't supported in this case or I don't have the projections defined correctly.  Any ideas?  I'm using Spring Boot version 2.0.3.</p>