I have a lot of DTO interfaces which I’m using with Immutables like this one:
@Value.Immutable
public interface UserTeamDto extends BaseRelationshipDto {
I’m also using them with Mapstruct to transform those DTOs into Entities (and vice-versa) using some generic mapper classes, and its working well:
D toParentDto(E pParentEntity, @Context MC pMapperContext);
But I have multiple cases (Many to Many relatioships) where I need to use @Context callback events and I need to pass the generated Builder to the mapping method.
@AfterMapping
public void processChildDto(@MappingTarget ImmutableUserDto.Builder pParentEntity) {
....
}
But I would like to find a way to do this generically too.
One thing that I thought was to make the Build to implement a common interface as well as I do in the origin interface, but I couldn’t find a way to setup this on Immutables for all DTO interfaces that extends BaseRelationshipDto.
Is there any way to do this ?