#2755: use raw Type when calling a static method. (#2762)

This commit is contained in:
Zegveld 2022-03-12 18:02:01 +01:00 committed by GitHub
parent b6a3aa1512
commit 0a69492983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 1 deletions

View File

@ -15,7 +15,7 @@
<#if static><@includeModel object=providingParameter.type/><#else>${providingParameter.name}</#if>.<@methodCall/>
<#-- method is referenced java8 static method in the mapper to implement (interface) -->
<#elseif static>
<@includeModel object=definingType/>.<@methodCall/>
<@includeModel object=definingType raw=true/>.<@methodCall/>
<#elseif constructor>
new <@includeModel object=definingType/><#if (parameterBindings?size > 0)>( <@arguments/> )<#else>()</#if>
<#elseif methodChaining>

View File

@ -0,0 +1,48 @@
/*
* 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.selection.generics;
import java.util.Map;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;
import org.mapstruct.factory.Mappers;
public interface GenericMapperBase<T> {
T toDto(Map<String, Property> prop);
@Named( "StringArrayToString" )
static String stringArrayToString(Property property) {
return "converted";
}
}
class Property {
}
class ProjectDto {
private String productionSite;
public void setProductionSite(String productionSite) {
this.productionSite = productionSite;
}
public String getProductionSite() {
return productionSite;
}
}
@Mapper
interface ProjectMapper extends GenericMapperBase<ProjectDto> {
ProjectMapper INSTANCE = Mappers.getMapper( ProjectMapper.class );
@Mapping( target = "productionSite", source = "productionSite", qualifiedByName = "StringArrayToString" )
@Override
ProjectDto toDto(Map<String, Property> projectProp);
}

View File

@ -0,0 +1,25 @@
/*
* 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.selection.generics;
import org.mapstruct.ap.testutil.IssueKey;
import org.mapstruct.ap.testutil.ProcessorTest;
import org.mapstruct.ap.testutil.WithClasses;
/**
* @author Ben Zegveld
*/
@WithClasses( {
GenericMapperBase.class
} )
@IssueKey( "2755" )
class GenericMapperBaseTest {
@ProcessorTest
void generatesCompilableCode() {
}
}