title: How to use decorated method in Mapstruct collection mapper?
body: <p>I am using MapStruct to map from a JPA entity to a POJO DTO, in a Spring app with dependency injection.</p>
  
  <p>I have added some additional processing of the DTO to a method in a decorator <a href="http://mapstruct.org/documentation/1.0/reference/html/index.html#customizing-mappers-using-decorators" rel="noreferrer">as specified in the doc</a>.</p>
  
  <p>It works fine for mapping a single entity. But I also have a mapping for a collection (set) of these entities and the method is called automatically when a collection of those entities is found in a relationship.</p>
  
  <p>However the generated collection mapping method does not use the decorated method to map each entity, is just uses the "vanilla" generated method on the delegate. Here is the code of the generated method :</p>
  
  <pre><code>@Override
  public Set&lt;DimensionItemTreeDTO&gt; missionSetToTreeDtoSet(Set&lt;Mission&gt; set)  {
      return delegate.missionSetToTreeDtoSet( set );
  }
  </code></pre>
  
  <p>The delegate method itself is not aware of the decorator and calls the individual item mapping method on itself :</p>
  
  <pre><code>@Override
  public Set&lt;DimensionItemTreeDTO&gt; missionSetToTreeDtoSet(Set&lt;Mission&gt; set) {
      if ( set == null ) {
          return null;
      }
  
      Set&lt;DimensionItemTreeDTO&gt; set__ = new HashSet&lt;DimensionItemTreeDTO&gt;();
      for ( Mission mission : set ) {
          set__.add( missionToTreeDto( mission ) ); //here the decorator is not called !
      }
  
      return set__;
  }
  </code></pre>
  
  <p>...and the decorated method is never called for the items inside the collection.</p>
  
  <p>Is there a way I can make Mapstruct use the decorator method in the collection mappings, short of writing the collection method manually in my decorator (which works but is verbose and defeats the purpose of having MapStruct in the first place which is not to have to write this kind of code) ?</p>