-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
Raising this issue as mentioned: https://stackoverflow.com/questions/68766859/fix-for-ambiguous-mapping-methods-found-for-mapping-property-error-on-qualifier#comment121545648_68767875
This triggers ambiguous mapping methods found for mapping property error on versions 1.3.1.Final and 1.4.2.Final
@Mapper( uses = MappingUtil.class )
public interface SourceTargetMapper {
SourceTargetMapper MAPPER = Mappers.getMapper( SourceTargetMapper.class );
@Mapping(source = "map", target = "aProperty", qualifiedBy = A.class )
@Mapping(source = "map", target = "bProperty", qualifiedBy = B.class )
Target toTarget(Map<String,Map<String, Object>> map);
}
public class MappingUtil {
@Qualifier
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface A {
}
@Qualifier
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface B {
}
@A
public String abc(Map<String,Map<String, Object>> in) {
return (String) in.get("first_key").get("a_second_key");
}
@B
public String xyz(Map<String,Map<String, Object>> in) {
return (String) in.get("first_key").get("b_second_key");
}
}When I change either @A or @B to a different type, the error goes away
@B
public int xyz(Map<String,Map<String, Object>> in) {
return (int) in.get("first_key").get("b_second_key");
}Current fix was to use the proposed alternative solution of using qualifiedByName and @nAmed instead of creating a separate utility class
Reactions are currently unavailable