Skip to content

Conversation

@thunderhook
Copy link
Contributor

closes #236

I tried to disable it by excluding it in the MapstructReferenceContributor when using the elementPattern` but somehow this did not get called.

Therefore I used the check inside shouldRegisterProblem(...) to exclude it.

Copy link
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.

Thanks @thunderhook.

Does this also work properly if we have something like:

@Retention(RetentionPolicy.CLASS)
@Mappings({
    @Mapping(target = "id", ignore = true),
    @Mapping(target = "creationDate", expression = "java(new java.util.Date())"),
    @Mapping(target = "name", source = "groupName")
})
@interface ToEntity { }

Comment on lines 76 to 78
return Optional.ofNullable( PsiTreeUtil.getParentOfType( element, PsiClass.class ) )
.map( PsiClass::isAnnotationType )
.orElse( false );
Copy link
Member

Choose a reason for hiding this comment

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

There is really no need to use ofNullable here. I prefer assigning this to a value and doing a good old regular null check.

@thunderhook
Copy link
Contributor Author

Thanks @thunderhook.

Does this also work properly if we have something like:

@Retention(RetentionPolicy.CLASS)
@Mappings({
    @Mapping(target = "id", ignore = true),
    @Mapping(target = "creationDate", expression = "java(new java.util.Date())"),
    @Mapping(target = "name", source = "groupName")
})
@interface ToEntity { }

I had a look at it, and yes it works. Added a test for this as well.

@filiphr filiphr merged commit f2abfa0 into main Jul 31, 2025
13 checks passed
@filiphr filiphr deleted the 236 branch July 31, 2025 21:18
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.

Disable unknown properties on mapping composition annotations

3 participants