Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</#list>
</#if>
</#list>
<#else>
<#elseif !propertyMappingsByParameter(sourceParameters[0]).empty>
<#if mapNullToDefault>if ( <@includeModel object=getPresenceCheckByParameter(sourceParameters[0]) /> ) {</#if>
<#list propertyMappingsByParameter(sourceParameters[0]) as propertyMapping>
<@includeModel object=propertyMapping targetBeanName=resultName existingInstanceMapping=existingInstanceMapping defaultValueAssignment=propertyMapping.defaultValueAssignment/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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._3747;

import org.mapstruct.Mapper;
import org.mapstruct.NullValueMappingStrategy;

/**
* @author Filip Hrisafov
*/
@Mapper(nullValueMappingStrategy = NullValueMappingStrategy.RETURN_DEFAULT)
public interface Issue3747Mapper {

Target map(Source source);

class Source {
private final String value;

public Source(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}

class Target {
private final String value;

public Target(String value) {
this.value = value;
}

public String getValue() {
return value;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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._3747;

import org.junit.jupiter.api.extension.RegisterExtension;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.GeneratedSource;

/**
* @author Filip Hrisafov
*/
@IssueKey("3747")
@WithClasses(Issue3747Mapper.class)
class Issue3747Test {

@RegisterExtension
final GeneratedSource generatedSource = new GeneratedSource();

@ProcessorTest
void shouldNotGenerateObsoleteCode() {
generatedSource.addComparisonToFixtureFor( Issue3747Mapper.class );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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._3747;

import javax.annotation.processing.Generated;

@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-03T12:50:02+0100",
comments = "version: , compiler: javac, environment: Java 21.0.3 (N/A)"
)
public class Issue3747MapperImpl implements Issue3747Mapper {

@Override
public Target map(Source source) {

String value = null;
if ( source != null ) {
value = source.getValue();
}

Target target = new Target( value );

return target;
}
}