Jordi
Jordi

Reputation: 23207

Mapstruct: aftermapping with parameters

Here my code:

@Mapping(target = "auditoriaMetas", qualifiedByName = "sdf")
public abstract Auditoria mapToModificacio(QdCF qdcf, QdCFPresenter qdcfPresenter, Integer idInstrument);

@Named("sdf")
public List<AuditoriaMeta> mapToMetas(QdCF current, @Context QdCFPresenter incoming) {
    return null;
}

I want that after mapToModificatio is performed, mapToMetas is also executed.

Above code doesn't perform.

Any ideas?

Upvotes: 0

Views: 530

Answers (1)

Ben Zegveld
Ben Zegveld

Reputation: 1506

Mapstruct will not consider putting a normal value into one that is annotated with @Context. Therefor if you mark something with @Context, then it should be marked like that through the entire chain of calls.

For example:

@Mapping(target = "auditoriaMetas", source=".", qualifiedByName = "sdf")
public abstract Auditoria mapToModificacio(QdCF qdcf, @Context QdCFPresenter qdcfPresenter, Integer idInstrument);

@Named("sdf")
public List<AuditoriaMeta> mapToMetas(QdCF current, @Context QdCFPresenter incoming) {
    return null;
}

Upvotes: 2

Related Questions