title: Can I extend MapStruct methods?
body: <p>I'm developing a library and I expect the library to have a mapper like so:</p>
  <pre class="lang-java prettyprint-override"><code>import org.mapstruct.*;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.factory.annotation.Qualifier;
  import spring.graphql.rest.rql.core.nodes.PropertyNode;
  import spring.graphql.rest.rql.core.nodes.TraversalMapper;
  import spring.graphql.rest.rql.example.dto.AccountDto;
  import spring.graphql.rest.rql.example.models.Account;
  
  import java.util.*;
  
  @Mapper(componentModel = &quot;spring&quot;, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
          nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE, uses = {TraversalMapper.class})
  public abstract class AccountMapper {
  
      @Autowired
      @Qualifier(&quot;accountMapperImpl&quot;)
      protected AccountMapper accountMapper;
  
      @Autowired
      protected PostMapper postMapper;
  
      @Autowired
      protected PersonMapper personMapper;
  
      @Autowired
      protected CommentMapper commentMapper;
  
      @IterableMapping(qualifiedByName = &quot;dynamicAccounts&quot;)
      public abstract Set&lt;AccountDto&gt; rqlToAccountDtos(Set&lt;Account&gt; entity, @Context StringBuilder currentPath, @Context List&lt;PropertyNode&gt; propertyNodes, @Context List&lt;String&gt; properties, @Context String property);
  
      // TODO: Implement automatic generation/addition of these mappers
      @Named(&quot;dynamicAccounts&quot;)
      @Mapping(target = &quot;friends&quot;, expression = &quot;java(properties.contains(\&quot;friends\&quot;) ? accountMapper.rqlToAccountDtos(entity.getFriends(), currentPath, propertyNodes, properties, \&quot;friends\&quot;) : null)&quot;)
      @Mapping(target = &quot;posts&quot;, expression = &quot;java(properties.contains(\&quot;posts\&quot;) ? postMapper.toPostDtos(entity.getPosts(), currentPath, propertyNodes, properties, \&quot;posts\&quot;) : null)&quot;)
      @Mapping(target = &quot;comments&quot;, expression = &quot;java(properties.contains(\&quot;comments\&quot;) ? commentMapper.toCommentDtos(entity.getComments(), currentPath, propertyNodes, properties, \&quot;comments\&quot;) : null)&quot;)
      @Mapping(target = &quot;person&quot;, expression = &quot;java(properties.contains(\&quot;person\&quot;) ? personMapper.toPersonDto(entity.getPerson(), currentPath, propertyNodes, properties, \&quot;person\&quot;) : null)&quot;)
      public abstract AccountDto rqlToAccountDto(Account entity, @Context StringBuilder currentPath, @Context List&lt;PropertyNode&gt; propertyNodes, @Context List&lt;String&gt; properties, @Context String property);
  
      @Named(&quot;dynamicAccountsDefaultCollection&quot;)
      public Set&lt;AccountDto&gt; toAccountDtosDefault(Collection&lt;Account&gt; entity, @Context List&lt;PropertyNode&gt; propertyNodes) {
          return rqlToAccountDtos(new HashSet&lt;&gt;(entity), new StringBuilder(), propertyNodes, new ArrayList&lt;&gt;(), &quot;&quot;);
      }
  
      @Named(&quot;dynamicAccountsDefault&quot;)
      public AccountDto toAccountDtoDefault(Account entity, @Context List&lt;PropertyNode&gt; propertyNodes) {
          return rqlToAccountDto(entity, new StringBuilder(), propertyNodes, new ArrayList&lt;&gt;(), &quot;&quot;);
      }
  }
  </code></pre>
  <p>Which is meant for internal remapping. Now, I'd like to add a feature where the user can &quot;override&quot; this method, in the sense that they could for example add a statement to ignore the password of the account, while also calling the internal methods.</p>
  <p>Few examples as reference points:</p>
  <pre class="lang-java prettyprint-override"><code>import org.mapstruct.*;
  import spring.graphql.rest.rql.core.nodes.PropertyNode;
  import spring.graphql.rest.rql.example.dto.AccountDto;
  import spring.graphql.rest.rql.example.models.Account;
  
  import java.util.List;
  
  @Mapper(componentModel = &quot;spring&quot;, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
          nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
  public abstract class RealAccountMapper extends AccountMapper {
  
      @Mapping(target = &quot;username&quot;, ignore = true)
      public abstract AccountDto toAccountDtoDefault(Account entity, @Context List&lt;PropertyNode&gt; propertyNodes);
  }
  
  @Mapper(componentModel = &quot;spring&quot;, nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS,
          nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
  public abstract class RealAccountMapper {
  
      @Mapping(target = &quot;username&quot;, ignore = true)
      @Mapper(uses = AccountMapper.class, qualifiedByName = &quot;dynamicAccountsDefault&quot;)
      public abstract AccountDto toAccountDto(Account entity, @Context List&lt;PropertyNode&gt; propertyNodes);
  }
  </code></pre>
  <p>The user should be able to define a property to ignore, or for example add with a specified source. From what I experimented, even without the overrides and such, it just generates a separate mapping method, instead of even trying to reuse the other one.</p>
  <p>Is this possible without needing to implement custom methods on the user side which would call the internal methods? If not, is there a particular reason, or has it just not come up as a possible feature in MapStruct?</p>