title: MapStruct @Mapping whithout source parameter
body: <p>I need to convert a <code>dto</code> to <code>entity</code> and the <code>entity</code> has a field to populate which doesn't needs any field of the <code>dto</code>. Indeed, the <code>@Mapping</code> annotation doesn't take any source.</p>
  <p>Let's illustrate it with this simple example :</p>
  <pre><code>public class Employee {
      private String firstName;
      private String customId;
  }
  
  public class EmployeeDto {
      private String firstName;
  }
  </code></pre>
  <p>As you can the field <code>customId</code> of the <code>Employee</code> entity doesn't exist in the <code>EmployeeDTO</code>.</p>
  <p>Also, I have the following <code>formatter</code>. Obviously, I created an <code>@CustomIdGenerator</code> <code>@interface</code></p>
  <pre><code>public class EmployeeFormatter {
      @CustomIdGenerator
      public static String simulationIdGenerator() {
         return // businessLogic
      }
  }
  </code></pre>
  <p>And finally my mapper looks like this :</p>
  <pre><code>@Mapper(uses = EmployeeFormatter.class)
  public abstract class EmployeeMapper {
  
      @Mapping(target = &quot;customId&quot;, qualifiedBy = customIdGenerator.class)
      public abstract Employee toEmployee(EmployeeDTO dto);
  
  }
  </code></pre>
  <p>But in the generated classes it doesn't work. Do you know if there is any way to use a mapper whithout parameter ?</p>
  <p>Thanks for your help ;)</p>
  <p><strong>EDIT :</strong></p>
  <p>Based on the response of @Nikolai Shevchenko the following code works :</p>
  <pre><code>  @AfterMapping
      void setCustomId(@MappingTarget Employee employee) {
          employee.setCustomId(EmployeeFormatter.customIdGenerator());
      }
  </code></pre>