Skip to content

Use of target type annotations as processing instruction#43

Merged
sjaakd merged 2 commits intomapstruct:masterfrom
sjaakd:annotations
Nov 3, 2018
Merged

Use of target type annotations as processing instruction#43
sjaakd merged 2 commits intomapstruct:masterfrom
sjaakd:annotations

Conversation

@sjaakd
Copy link
Copy Markdown
Contributor

@sjaakd sjaakd commented May 3, 2018

This example demonstrates a few things:

  • use of @Contextand @BeforeMapping on context to store the target annotation information.
  • using @IgnoreAll annotation to make sure mapping methods are not directly triggered (@filiphr .. perhaps we should add this to MapStruct by default or document is as pattern.. I - for one - find it very usable.
  • using annotation information for directing the mapping in a handwritten conversion method.

}
}

@IgnoreMapping
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this qualifier? I can't find a place where it is used.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a method is marked with a Qualifier MapStruct will not use it in the default options for choosing a method. Thus Sjaak called this @IgnoreMapping. This would mean that when mapping TaxRecord to TaxRecordPE only convert(LegalEntity s, @Context TaxContext ctx) would be considered as an option

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just mention that this uses reflection (we are usually reflection free 😄)

done. Also clarified / renamed the @IgnoreMapping

Copy link
Copy Markdown
Member

@filiphr filiphr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting example @sjaakd.

Maybe we can just mention that this uses reflection (we are usually reflection free 😄)

LGTM

@sjaakd sjaakd merged commit c494cc3 into mapstruct:master Nov 3, 2018
@sjaakd
Copy link
Copy Markdown
Contributor Author

sjaakd commented Nov 3, 2018

@filiphr , @chris922 thanks for reviewing

@sjaakd sjaakd deleted the annotations branch November 3, 2018 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants