mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2901: Fix @TargetType
annotation on a @Condition
annotated method for a Collection value
This commit is contained in:
parent
849085e026
commit
17997ef617
@ -60,7 +60,8 @@
|
||||
<#macro handleLocalVarNullCheck needs_explicit_local_var>
|
||||
<#if sourcePresenceCheckerReference??>
|
||||
if ( <@includeModel object=sourcePresenceCheckerReference
|
||||
targetPropertyName=ext.targetPropertyName/> ) {
|
||||
targetType=ext.targetType
|
||||
targetPropertyName=ext.targetPropertyName /> ) {
|
||||
<#if needs_explicit_local_var>
|
||||
<@includeModel object=nullCheckLocalVarType/> ${nullCheckLocalVarName} = <@lib.handleAssignment/>;
|
||||
<#nested>
|
||||
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* 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._2901;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mapstruct.Condition;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.TargetType;
|
||||
|
||||
@Mapper
|
||||
public interface ConditionWithTargetTypeOnCollectionMapper {
|
||||
|
||||
Target map(Source source);
|
||||
|
||||
@Condition
|
||||
default boolean check(List<String> test, @TargetType Class<?> type) {
|
||||
return type.isInstance( test );
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* 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._2901;
|
||||
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@IssueKey( "2901" )
|
||||
class Issue2901Test {
|
||||
|
||||
@ProcessorTest
|
||||
@WithClasses( { Source.class, Target.class, ConditionWithTargetTypeOnCollectionMapper.class } )
|
||||
void shouldCompile() {
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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._2901;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Source {
|
||||
|
||||
private List<String> field;
|
||||
|
||||
public List<String> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(List<String> field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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._2901;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Target {
|
||||
|
||||
private List<Integer> field;
|
||||
|
||||
public List<Integer> getField() {
|
||||
return field;
|
||||
}
|
||||
|
||||
public void setField(List<Integer> field) {
|
||||
this.field = field;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user