title: How to add a derived list to a model object
body: <p>I'd like to add a derived list to a DTO/model object when mapping from an entity. For example, I have an entity class named Company that has a list of Employees. I'd like for the Company Model object to contain the list of Employees as well as a list of Employees who are Managers. (This is not my actual class names, but this type of thing is what I'm trying to do). So, I want the Company DTO to have a list of Employees and a list of Managers where the Managers is a subset of Employees that is derived by filtering the list of Employees. </p>
  
  <p>I tried using a mapping expression and a default method. However, I need to use the EmployeeMapper and it seems that I don't have access to the mapper.</p>
  
  <p>Here's what I tried... </p>
  
  <pre><code>@Mapper(componentModel = "spring", uses = {EmployeeMapper.class})
  public interface CompanyMapper extends IEntityMapper&lt;CompanyModel, Entity&gt; {
  
      @Mapping(expression = "java(deriveManagers(model))", target = "managers")
      EntityModel toModel(Company company);
  
      default List&lt;EmployeeModel&gt; deriveManagers(Company company) {
          List&lt;EmployeeModel&gt; managers = new ArrayList&lt;EmployeeModel&gt;();
  
          company.getEmployees().forEach(nextEmployee -&gt; {
            if (nextEmployee.getJobTitle().equals(JobTitle.MANAGER)) {
              managers.add(this.EmployeeMapper.toModel(nextEmployee);
            }
          });
  
          return managers;
      }
  }
  </code></pre>