Skip to content

Commit

Permalink
mapstruct#3703 Use include model instead of manually writing the type…
Browse files Browse the repository at this point in the history
… name for return type for afterMappingReferencesWithFinalizedReturnType
  • Loading branch information
filiphr committed Sep 14, 2024
1 parent 2686e85 commit 0298a12
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@

<#if finalizerMethod??>
<#if (afterMappingReferencesWithFinalizedReturnType?size > 0)>
${returnType.name} ${finalizedResultName} = ${resultName}.<@includeModel object=finalizerMethod />;
<@includeModel object=returnType /> ${finalizedResultName} = ${resultName}.<@includeModel object=finalizerMethod />;

<#list afterMappingReferencesWithFinalizedReturnType as callback>
<#if callback_index = 0>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3703;

import org.mapstruct.AfterMapping;
import org.mapstruct.Mapper;
import org.mapstruct.MappingTarget;
import org.mapstruct.ap.test.bugs._3703.dto.Contact;

@Mapper
public interface Issue3703Mapper {

Contact map(org.mapstruct.ap.test.bugs._3703.entity.Contact contact);

org.mapstruct.ap.test.bugs._3703.entity.Contact map(Contact contact);

@AfterMapping
default void afterMapping(@MappingTarget Contact target, org.mapstruct.ap.test.bugs._3703.entity.Contact contact) {
}

@AfterMapping
default void afterMapping(@MappingTarget Contact.Builder targetBuilder,
org.mapstruct.ap.test.bugs._3703.entity.Contact contact) {
}

@AfterMapping
default void afterMapping(@MappingTarget org.mapstruct.ap.test.bugs._3703.entity.Contact target, Contact contact) {
}

@AfterMapping
default void afterMapping(@MappingTarget org.mapstruct.ap.test.bugs._3703.entity.Contact.Builder targetBuilder,
Contact contact) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3703;

import org.mapstruct.ap.test.bugs._3703.dto.Contact;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;

@IssueKey("3703")
@WithClasses({
Contact.class,
org.mapstruct.ap.test.bugs._3703.entity.Contact.class,
Issue3703Mapper.class
})
public class Issue3703Test {

@ProcessorTest
void shouldCompile() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3703.dto;

public class Contact {

private final String name;

private Contact(String name) {
this.name = name;
}

public String getName() {
return name;
}

public static Builder newBuilder() {
return new Builder();
}

public static class Builder {

private String name;

public Builder name(String name) {
this.name = name;
return this;
}

public Contact build() {
return new Contact( name );
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.ap.test.bugs._3703.entity;

public class Contact {

private final String name;

private Contact(String name) {
this.name = name;
}

public String getName() {
return name;
}

public static Builder newBuilder() {
return new Builder();
}

public static class Builder {

private String name;

public Builder name(String name) {
this.name = name;
return this;
}

public Contact build() {
return new Contact( name );
}
}
}

0 comments on commit 0298a12

Please sign in to comment.