2

I have the following case:

**public class SimpleSource {
    private String name;
    private String description;
    // getters and setters
}
 
public class SimpleDestination {
    private String name__c;
    private String description__c;
    // getters and setters
 ContactMapper contactMapper = Mappers.getMapper(ContactMapper.class);
    @Mapping(source = "name", target = "name__c")
    @Mapping(source = "description", target = "description__c")

    Target__c customerContact(Source source);**

How can I avoid adding this @Mapping for all fields and just said that target has suffix "__c" targetFieldName = sourceFieldName+suffix

ibo
  • 21
  • 4

1 Answers1

1

MapStruct uses its AccessorNamingStrategy SPI to detect names of properties.

This means that in order to achieve what you are looking for you'll need to provide you own AccessorNamingStrategy.

You can read more about it in the MapStruct Documentation

Filip
  • 19,269
  • 7
  • 51
  • 60