icgc-argo / icgc-argo/program-service
Add custom handling of protobuf target conversion using Mapstruct SPI
Open
@rtisma is already working on this.
Since May 2, 2019.
- Dominant language
- Java
- Stars
- 3
- Forks
- 0
- Avg merge
- 14h 34m
- Merged PRs (30d)
- 2
Description
Background
- SPI = Service Provided Interface
- Mapstruct provides the interface to override the default naming strategy implementation used to extract info for mapping
Problem
- When the target is protobuf and all target fields must be mapped, there is an issue specifically with protobuf because there are fields such as
mergeFrom,clearOneOf, which mapstruct labels asfluent settersand so looks to find the associated field, but doesnt find any.
- Also, becuase protobuf setter names use
setCarListinstead ofsetCars, inorder to be compatible with lombok, this needs to be overrided too
Solution
-
Solution to 1
- Override so that if its a protobuf message,
isFluentSetteralways returnsfalse, otherwise works as normal. - will eliminate the
mergeFrom,clearOneOfissue you get when converting with mapstruct - Using Mapstruct SPI
- Example Repo of Creating Custom Naming Strategy
- refer to
src/main/resources/META-INF/servicesfor overriding the defaul accessor naming strategy - refer to ProtobufAccessorNamingStrategy
- refer to
- Override so that if its a protobuf message,
-
Solution to 2
- Can fix the List issue using the exact example in ProtobufAccessorNamingStrategy
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.
Assessment
This issue has not been assessed yet.