mapstruct / mapstruct/mapstruct
Static private methods should be generated in case of aaa.bbb to ccc mapping
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Java
- Stars
- 7.7k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Example:
public interface AddonMapper extends Function<Addon, AddonProxy> {
@Override
@Mapping(source = "addonCategory.value", target = "addonCategory")
@Mapping(source = "addonCategory.translation", target = "addonCategoryTranslated")
AddonProxy apply(Addon addon);
}
// Generates private method like that, but this method should be STATIC:
private String addonAddonCategoryValue(Addon addon) {
if ( addon == null ) {
return null;
}
TranslatedValue addonCategory = addon.getAddonCategory();
if ( addonCategory == null ) {
return null;
}
String value = addonCategory.getValue();
if ( value == null ) {
return null;
}
return value;
}
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 from the example in the issue and trace how MapStruct generates private helper methods for nested mappings such as addonCategory.value. Determine where that generated method is selected for instance versus static generation. Done means the helper for this mapping is static while preserving the shown null-safe behavior, with corresponding generated-code coverage added where the project’s tests support it.
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
- 45/100