Skip to content

Commit f6080c5

Browse files
committed
#243: Code review adaptions
1 parent 88f76ba commit f6080c5

4 files changed

Lines changed: 43 additions & 18 deletions

File tree

src/main/java/org/mapstruct/intellij/util/MapstructUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ public static boolean isMapWithStringKeyType(@Nullable PsiType type) {
682682
}
683683

684684
PsiType[] parameters = ct.getParameters();
685-
if ( parameters.length == 0 ) {
685+
if ( parameters.length != 2 ) {
686686
return false;
687687
}
688688

src/test/java/org/mapstruct/intellij/bugs/_243/DisableSourcePropertyInspectionOnMapTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ protected Class<MapstructReferenceInspection> getInspection() {
2525
return MapstructReferenceInspection.class;
2626
}
2727

28-
public void testDisableSourcePropertyInspectionOnMapTest() {
28+
public void testDisableSourcePropertyInspectionOnMap() {
29+
doTest();
30+
}
31+
32+
public void testDisableSourcePropertyInspectionOnMapErroneous() {
2933
doTest();
3034
}
3135
}

testData/bugs/_243/DisableSourcePropertyInspectionOnMapTest.java renamed to testData/bugs/_243/DisableSourcePropertyInspectionOnMap.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,6 @@ abstract class Issue243Mapper {
2424
@Mapping(source = "exDate", target = "exDate")
2525
public abstract CorporateAction mapWithObjectValueMap(Map<String, Object> rowValues);
2626

27-
@Mapping(source = "<error descr="Unknown property 'exDate'">exDate</error>", target = "exDate")
28-
public abstract CorporateAction mapWithIntegerKeyMap(Map<Integer, String> rowValues);
29-
30-
@Mapping(source = "<error descr="Unknown property 'exDate'">exDate</error>", target = "exDate")
31-
public abstract void updateWithIntegerKeyMap(
32-
Map<Integer, String> rowValues,
33-
@MappingTarget CorporateAction target
34-
);
35-
36-
@Mapping(source = "<error descr="Unknown property 'exDate'">exDate</error>", target = "exDate")
37-
@Mapping(source = "payDate", target = "payDate")
38-
public abstract CorporateAction mapWithMultipleSources(
39-
Map<String, String> rowValues,
40-
LocalDate payDate
41-
);
42-
4327
@Mapping(source = "rowValues.exDate", target = "exDate")
4428
@Mapping(source = "payDate", target = "payDate")
4529
public abstract CorporateAction mapWithMultipleSourcesAndMapName(
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright MapStruct Authors.
3+
*
4+
* Licensed under the Apache License version 2.0, available at https://www.apache.org/licenses/LICENSE-2.0
5+
*/
6+
7+
import java.time.LocalDate;
8+
import java.util.Map;
9+
10+
import org.mapstruct.Mapper;
11+
import org.mapstruct.Mapping;
12+
import org.mapstruct.MappingTarget;
13+
14+
@Mapper
15+
abstract class Issue243ErroneousMapper {
16+
17+
@Mapping(source = "<error descr="Unknown property 'exDate'">exDate</error>", target = "exDate")
18+
public abstract CorporateAction mapWithIntegerKeyMap(Map<Integer, String> rowValues);
19+
20+
@Mapping(source = "<error descr="Unknown property 'exDate'">exDate</error>", target = "exDate")
21+
public abstract void updateWithIntegerKeyMap(
22+
Map<Integer, String> rowValues,
23+
@MappingTarget CorporateAction target
24+
);
25+
26+
@Mapping(source = "<error descr="Unknown property 'exDate'">exDate</error>", target = "exDate")
27+
@Mapping(source = "payDate", target = "payDate")
28+
public abstract CorporateAction mapWithMultipleSources(
29+
Map<String, String> rowValues,
30+
LocalDate payDate
31+
);
32+
}
33+
34+
class CorporateAction {
35+
public LocalDate exDate;
36+
public LocalDate payDate;
37+
}

0 commit comments

Comments
 (0)