Java / MapStruct Java Interview questions part 2
What is the purpose of the @Mapper annotation?
@Mapper marks an interface (or abstract class) as a MapStruct mapping contract. When the project is compiled, the MapStruct annotation processor scans for this annotation and generates a concrete implementation class alongside it, typically named with an Impl suffix.
The annotation also carries configuration such as componentModel, which controls how the generated class is instantiated (plain factory, Spring bean, CDI bean), and uses, which lists helper mappers the generated code can delegate to.
@Mapper public interface CarMapper { CarDto carToCarDto(Car car); }
More Related questions...