Skip to content

Commit 71a6ef4

Browse files
sjaakdagudian
authored andcommitted
mapstruct#955 Import type param type when call to upd. method for coll.impl type
1 parent d83be86 commit 71a6ef4

7 files changed

Lines changed: 218 additions & 0 deletions

File tree

processor/src/main/java/org/mapstruct/ap/internal/model/assignment/UpdateWrapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public Set<Type> getImportTypes() {
7878
imported.addAll( super.getImportTypes() );
7979
if ( targetImplementationType != null ) {
8080
imported.add( targetImplementationType );
81+
imported.addAll( targetImplementationType.getTypeParameters() );
8182
}
8283
return imported;
8384
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._955;
20+
21+
import org.mapstruct.Mapper;
22+
import org.mapstruct.MappingTarget;
23+
import org.mapstruct.ap.test.bugs._955.dto.Car;
24+
import org.mapstruct.ap.test.bugs._955.dto.SuperCar;
25+
import org.mapstruct.factory.Mappers;
26+
27+
/**
28+
*
29+
* @author Sjaak Derksen
30+
*/
31+
@Mapper(uses = {CustomMapper.class})
32+
public interface CarMapper {
33+
34+
CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );
35+
36+
SuperCar mapCar(Car source, @MappingTarget SuperCar destination);
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._955;
20+
21+
import java.util.Map;
22+
import org.mapstruct.MappingTarget;
23+
import org.mapstruct.ap.test.bugs._955.dto.Person;
24+
25+
/**
26+
*
27+
* @author Sjaak Derksen
28+
*/
29+
public class CustomMapper {
30+
31+
public Map<String, Person> merge(Map<String, Person> source, @MappingTarget Map<String, Person> destination) {
32+
return destination;
33+
}
34+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._955;
20+
21+
import org.junit.Test;
22+
import org.junit.runner.RunWith;
23+
import org.mapstruct.ap.test.bugs._955.dto.Car;
24+
import org.mapstruct.ap.test.bugs._955.dto.Person;
25+
import org.mapstruct.ap.test.bugs._955.dto.SuperCar;
26+
import org.mapstruct.ap.testutil.IssueKey;
27+
import org.mapstruct.ap.testutil.WithClasses;
28+
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
29+
30+
/**
31+
*
32+
* @author Sjaak Derksen
33+
*/
34+
@IssueKey( "955" )
35+
@RunWith(AnnotationProcessorTestRunner.class)
36+
@WithClasses( { CarMapper.class, CustomMapper.class, Car.class, SuperCar.class, Person.class } )
37+
public class Issue955Test {
38+
39+
@Test
40+
public void shouldCompile() { }
41+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._955.dto;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
/**
25+
*
26+
* @author Sjaak Derksen
27+
*/
28+
public class Car {
29+
private Map<String, Person> persons = new HashMap<String, Person>();
30+
31+
public Map<String, Person> getPersons() {
32+
return persons;
33+
}
34+
35+
public void setPersons(Map<String, Person> persons) {
36+
this.persons = persons;
37+
}
38+
39+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._955.dto;
20+
21+
/**
22+
*
23+
* @author Sjaak Derksen
24+
*/
25+
public class Person {
26+
27+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
3+
* and/or other contributors as indicated by the @authors tag. See the
4+
* copyright.txt file in the distribution for a full listing of all
5+
* contributors.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.mapstruct.ap.test.bugs._955.dto;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
/**
25+
*
26+
* @author Sjaak Derksen
27+
*/
28+
public class SuperCar {
29+
private Map<String, Person> persons = new HashMap<String, Person>();
30+
31+
public Map<String, Person> getPersons() {
32+
return persons;
33+
}
34+
35+
public void setPersons(Map<String, Person> persons) {
36+
this.persons = persons;
37+
}
38+
39+
}

0 commit comments

Comments
 (0)