title: How can I use another mapping from different class in mapstruct
body: <p>I would like to mapping a model object to dto model. I already have mapper for one of the object.
  How can I reuse this mapper in another mapper which is in another class?</p>
  <p>I have below as model</p>
  <pre><code>    @Getter
      @AllArgsConstructor
      @ToString
      public class History {
  
        @JsonProperty(&quot;identifier&quot;)
        private final Identifier identifier;
  
      @JsonProperty(&quot;submitTime&quot;)
      private final ZonedDateTime submitTime;
  
      @JsonProperty(&quot;method&quot;)
      private final String method;
  
      @JsonProperty(&quot;reason&quot;)
      private final String reason;
  
      @JsonProperty(&quot;dataList&quot;)
      private final List&lt;Data&gt; dataList;
     }
  
       @DynamoDBTable(tableName = &quot;history&quot;)
       @Data
       @NoArgsConstructor
       public class HistoryDynamo {
          @DynamoDBRangeKey(attributeName = &quot;submitTime&quot;)
          @DynamoDBTypeConverted(converter = ZonedDateTimeType.Converter.class)
          private ZonedDateTime submitTime;
  
          @DynamoDBAttribute(attributeName = &quot;identifier&quot;)
          @NonNull
          private Identifier identifier;
  
          @DynamoDBAttribute(attributeName = &quot;method&quot;)
          private String method;
  
           @DynamoDBAttribute(attributeName = &quot;reason&quot;)
           private String reason;
  
           @DynamoDBAttribute(attributeName = &quot;dataList&quot;)
           private List&lt;Data&gt; dataList;
       }
  
          @Data
          @DynamoDBDocument
          @NoArgsConstructor
          public class Identifier implements Serializable {
      
              @DynamoDBAttribute(attributeName = &quot;number&quot;)
              private String number;
      
          @DynamoDBAttribute(attributeName = &quot;cityCode&quot;)
          @NonNull
          private String cityCode;
      
          @DynamoDBAttribute(attributeName = &quot;countryCode&quot;)
          @NonNull
          private String countryCode;
      
          @DynamoDBTypeConverted(converter = LocalDateType.Converter.class)
          private LocalDate mydate;
      }
      
           @Data
           @EqualsAndHashCode
           @NoArgsConstructor
           @RequiredArgsConstructor
           @JsonInclude(JsonInclude.Include.NON_NULL)
           public class Identifier implements Serializable {
      
          @NonNull
          @lombok.NonNull
          @NotNull
          private String number;
      
          @NonNull
          @lombok.NonNull
          @NotNull
          private City city;
      
          @NonNull
          @lombok.NonNull
          @NotNull
          private Country country;
      
          @JsonDeserialize(using = LocalDateDeserializer.class)
          @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = &quot;yyyy-MM-dd'Z'&quot;)
          @DateTimeFormat(pattern = &quot;yyyy-MM-dd'Z'&quot;)
          @NonNull
          @lombok.NonNull
          @NotNull
          private LocalDate mydate;
      }
  </code></pre>
  <p>And here is my mapping</p>
  <pre><code>    @Mapper(componentModel = &quot;spring&quot;, unmappedTargetPolicy = ReportingPolicy.WARN, injectionStrategy = InjectionStrategy.CONSTRUCTOR, nullValueMappingStrategy = NullValueMappingStrategy.RETURN_NULL)
      public interface IdentifierMapper {
      
          IdentifierMapper MAPPER = Mappers.getMapper(IdentifierMapper.class);
      
      
          @Mappings({@Mapping(source = &quot;identifier.number&quot;, target = &quot;number&quot;),
                     @Mapping(source = &quot;identifier.city.code&quot;, target = &quot;cityCode&quot;),
                     @Mapping(source = &quot;identifier.country.code&quot;, target = &quot;countryCode&quot;),
                     @Mapping(source = &quot;identifier.mydate&quot;, target = &quot;mydate&quot;)})
          @Named(&quot;toIdentifierDynamo&quot;)
          myproject.entity.dynamo.Identifier toIdentifierDynamo(myproject.model.Identifier identifier);
      }
      
      @Mapper(componentModel = &quot;spring&quot;, unmappedTargetPolicy = ReportingPolicy.WARN, injectionStrategy = InjectionStrategy.CONSTRUCTOR,
              nullValueMappingStrategy = NullValueMappingStrategy.RETURN_NULL, uses = {IdentifierMapper.class})
      public interface HistoryMapper {
      
          HistoryMapper MAPPER = Mappers.getMapper(HistoryMapper.class);
      
          @Mappings({@Mapping(source = &quot;identifier&quot;, target = &quot;identifier&quot;, qualifiedByName = &quot;toIdentifierDynamo&quot;),
                    @Mapping(source = &quot;method&quot;, target = &quot;method&quot;),
                    @Mapping(source = &quot;reason&quot;, target = &quot;reason&quot;),
                    @Mapping(source = &quot;timestamp&quot;, target = &quot;timestamp&quot;)})
          HistoryDynamo toHistoryDynamo(History history);
      }
  </code></pre>
  <p>I would like to map History to HistoryDynamo and reuse IdentifierMapper to map one of the object in HistoryDynamo.
  How can I use toIdentifierDynamo in toHistoryDynamo?</p>