GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add `@SourcePropertyName` to handle a property name of the source object · Issue #3323 · mapstruct/mapstruct

Add @SourcePropertyName to handle a property name of the source object #3323

New issue
Copy link
New issue
Copy link
Closed
#3508
Closed
Add @SourcePropertyName to handle a property name of the source object#3323
#3508
Copy link
Labels
feature
Milestone
1.6.0.Beta2

Description

@filiphr
filiphr
opened on Jul 9, 2023
Issue body actions

A suggestion from #3313 (comment)

Activity

Next
  1. filiphr
    added
    for:team-discussion
    on Jul 9, 2023
  2. filiphr
    added this to the 1.6.0 milestone on Jul 9, 2023
  3. filiphr commented on Jul 9, 2023

    @filiphr
    filiphr
    on Jul 9, 2023
    MemberAuthor
    More actions

    We might actually need a new @SourcePropertyName to have the source property. Currently all our tests use implicit mapping, and in this case the source and target property names are identical.

  4. filiphr
    added
    enhancement
    and removed
    for:team-discussion
    on Oct 2, 2023
  5. filiphr commented on Oct 2, 2023

    @filiphr
    filiphr
    on Oct 2, 2023
    MemberAuthor
    More actions

    Discussed with the team we are going to add @SourcePropertyName that would pass the name of the source property and @TargetPropertyName that would pass the target property name

  6. aboqasem
    added a commit that references this issue on Oct 7, 2023

    mapstruct#3323 different source -> target property name in test cases

    76e7067
  7. aboqasem commented on Oct 7, 2023

    @aboqasem
    aboqasem
    on Oct 7, 2023
    More actions

    Hello @filiphr & @babyfish-ct, I do not see where's the confusion in the name. It's indeed getting the target's property name as the name says. I added a test case that proves that: aboqasem@76e7067.

    Am I missing something?

  8. thunderhook commented on Oct 7, 2023

    @thunderhook
    thunderhook
    on Oct 7, 2023
    Contributor
    More actions

    @aboqasem I looked at the tests and the code and yes, indeed. The @TargetPropertyName handles the targets property name. So there will be an additional @SourcePropertyName annotation which handles the sources property name. I will rename this ticket to avoid any further confusion.

  9. thunderhook
    changed the title [-]Rename `@TargetPropertyName` to `@PropertyName`[/-] [+]Add `@SourcePropertyName` to handle a property name of the source object[/+] on Oct 7, 2023
  10. aboqasem commented on Oct 7, 2023

    @aboqasem
    aboqasem
    on Oct 7, 2023
    More actions

    Thank you @thunderhook!

    This is my first time contributing to MapStruct. May I try to contribute to implementing this?

    I started doing it and currently trying to understand what are the .ftl files (seems like they are for code gen). Then perhaps start with the org.mapstruct.ap.MappingProcessor class?

    Any tips or pointers would help!

  11. thunderhook commented on Oct 12, 2023

    @thunderhook
    thunderhook
    on Oct 12, 2023
    Contributor
    More actions

    What I would do in your case: Take a look at the commit where the @TargetPropertyName was introduced to see out how it works. I think the code for the @SourcePropertyName will be very similar.

    Yes, the .ftl files are Apache FreeMarker java templates which are used for the code generation of mappers (and all of their belongings). The org.mapstruct.ap.internal.processor.MapperCreationProcessor is the main processor that handles the creation of a mapper class.

    Another hint: When you run a test, e.g. the TargetPropertyNameTest, you can have a look at the generated sources and mappers that are generated and compiled in: ...\mapstruct\processor\target\compilation-tests\org.mapstruct.ap.test.conditional.targetpropertyname.TargetPropertyNameTest.

    If it is okay with @filiphr (I don't know if he's currently working on this issue) you are welcome to contribute!

    Reacted by Mohammad Al Zouabi
  12. aboqasem commented on Oct 14, 2023

    @aboqasem
    aboqasem
    on Oct 14, 2023
    More actions

    Thanks a lot, @thunderhook!

    I was looking for the generated classes in the wrong place, thanks for the hint!

    Let me try to check the good-first-issues first, since there's 5 of them at the moment.

  13. aboqasem
    added 2 commits that reference this issue on Oct 14, 2023

    mapstruct#3323 move `targetpropertyname` tests to `propertyname.targe…

    c9060ba

    mapstruct#3323 clone tests of `TargetPropertyName` for `SourcePropert…

    ffb1ce1
  14. 5 remaining items

  15. filiphr
    modified the milestones: 1.6.0.Beta2, 1.6.0.Beta1 on Nov 4, 2023
  16. markostijak commented on Dec 6, 2023

    @markostijak
    markostijak
    on Dec 6, 2023
    More actions

    Can we have something like @Source annotation as well, together with @SourcePropertyName.
    @Source should behave similar to the @Context annotation, but use mapping source parameter instead.

    My usecase is a localization, where localization keys are calculated based on entity ids and attribute names.

  17. filiphr commented on Dec 15, 2023

    @filiphr
    filiphr
    on Dec 15, 2023
    MemberAuthor
    More actions

    That makes sense @markostijak. That you are asking might be more in the direction of #2559.

    However, I would suggest to create a new issue for this, let's keep this issue only for @SourcePropertyName. Implementation wise it is really different

    Reacted by Marko Stijak
  18. thunderhook
    added 2 commits that reference this issue on Jan 7, 2024

    #3323 Support access to the source property name

    625dea5

    #3323 Support access to the source property name

    a6b0870
  19. thunderhook
    added 3 commits that reference this issue on Jan 28, 2024

    #3323 code review adpations

    d70be70

    #3323 code review adpations

    c55ea17

    #3323 code review adpations

    ee03898
  20. filiphr
    added a commit that references this issue on Feb 11, 2024

    #3323 Support access to the source property name

    8191c85
  21. filiphr
    closed this as completedin #3508on Feb 11, 2024
  22. filiphr
    added
    feature
    and removed
    enhancement
    on May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      • 1.6.0.Beta2

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.