mapstruct / mapstruct/mapstruct
Ignore fields by Suffix or type
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Use case
Hello,
I am using Mapstruct with Avro, and the generated class has builder fields that Mapstruct is trying to map.
Because of that, in every mapper, I have to ignore those fields:
import com.my.event.MyEventMapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@Mapper(
config = EventConfig.class)
public interface AvroMyEventMapper {
@Override
@Mapping(target = "metadata", source = "data")
@Mapping(target = "eventPayload", source="data")
@Mapping(target = "snapshotPayload", source = "booking")
@Mapping(target = "snapshotPayloadBuilder", ignore = true)
@Mapping(target = "metadataBuilder", ignore = true)
@Mapping(target = "eventPayloadBuilder", ignore = true)
AvroRefundRequestedEvent map(Data data);
}
Do you know which trick I can implement to avoid that ?
I tried with SPI by trying to ignore type which ends with Builder but without success for now, is SPI would it be the good way to do it ?
Thank you !
Generated Code
No response
Possible workarounds
No response
MapStruct Version
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MapStruct SPI approach described in the issue and the generated Avro mapper example. Investigate whether fields can be ignored by a suffix or type without repeating the three @Mapping(ignore = true) entries. Done means the shown mapper can exclude the generated Builder fields through supported configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100