mapstruct / mapstruct/mapstruct

Static private methods should be generated in case of aaa.bbb to ccc mapping

Open
#1,211 3 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.