mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1164 Make sure that all import types of a Type are imported for the collection and map wrappers
This commit is contained in:
parent
fdf37cf451
commit
bbff0c0349
@ -72,8 +72,7 @@ public class WrapperForCollectionsAndMaps extends AssignmentWrapper {
|
||||
public Set<Type> getImportTypes() {
|
||||
Set<Type> imported = new HashSet<Type>();
|
||||
imported.addAll( super.getImportTypes() );
|
||||
imported.add( nullCheckLocalVarType );
|
||||
imported.addAll( nullCheckLocalVarType.getTypeParameters() );
|
||||
imported.addAll( nullCheckLocalVarType.getImportTypes() );
|
||||
return imported;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||
* and/or other contributors as indicated by the @authors tag. See the
|
||||
* copyright.txt file in the distribution for a full listing of all
|
||||
* contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1164;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
class GenericHolder<T> {
|
||||
|
||||
private T value;
|
||||
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||
* and/or other contributors as indicated by the @authors tag. See the
|
||||
* copyright.txt file in the distribution for a full listing of all
|
||||
* contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1164;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@WithClasses( {
|
||||
Source.class,
|
||||
Target.class,
|
||||
GenericHolder.class,
|
||||
SourceTargetMapper.class
|
||||
} )
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
@IssueKey( "1164" )
|
||||
public class Issue1164Test {
|
||||
|
||||
@Test
|
||||
public void shouldCompile() {
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||
* and/or other contributors as indicated by the @authors tag. See the
|
||||
* copyright.txt file in the distribution for a full listing of all
|
||||
* contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1164;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
class Source {
|
||||
|
||||
public static class SourceNested {
|
||||
}
|
||||
|
||||
private List<List<SourceNested>> nestedLists;
|
||||
private Map<Integer, List<SourceNested>> nestedMaps;
|
||||
private GenericHolder<List<SourceNested>> genericHolder;
|
||||
|
||||
public List<List<SourceNested>> getNestedLists() {
|
||||
return nestedLists;
|
||||
}
|
||||
|
||||
public void setNestedLists(List<List<SourceNested>> nestedLists) {
|
||||
this.nestedLists = nestedLists;
|
||||
}
|
||||
|
||||
public Map<Integer, List<SourceNested>> getNestedMaps() {
|
||||
return nestedMaps;
|
||||
}
|
||||
|
||||
public void setNestedMaps(Map<Integer, List<SourceNested>> nestedMaps) {
|
||||
this.nestedMaps = nestedMaps;
|
||||
}
|
||||
|
||||
public GenericHolder<List<SourceNested>> getGenericHolder() {
|
||||
return genericHolder;
|
||||
}
|
||||
|
||||
public void setGenericHolder(GenericHolder<List<SourceNested>> genericHolder) {
|
||||
this.genericHolder = genericHolder;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||
* and/or other contributors as indicated by the @authors tag. See the
|
||||
* copyright.txt file in the distribution for a full listing of all
|
||||
* contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1164;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
@Mapper
|
||||
public abstract class SourceTargetMapper {
|
||||
|
||||
public abstract Target map(Source source);
|
||||
|
||||
protected List<List<Target.TargetNested>> mapLists(List<List<Source.SourceNested>> lists) {
|
||||
return new ArrayList<List<Target.TargetNested>>();
|
||||
}
|
||||
|
||||
protected Map<String, List<Target.MapNested>> map(Map<Integer, List<Source.SourceNested>> map) {
|
||||
return new HashMap<String, List<Target.MapNested>>();
|
||||
}
|
||||
|
||||
protected GenericHolder<List<Target.GenericNested>> map(GenericHolder<List<Source.SourceNested>> genericHolder) {
|
||||
return new GenericHolder<List<Target.GenericNested>>();
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
|
||||
* and/or other contributors as indicated by the @authors tag. See the
|
||||
* copyright.txt file in the distribution for a full listing of all
|
||||
* contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1164;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Filip Hrisafov
|
||||
*/
|
||||
class Target {
|
||||
|
||||
public static class TargetNested {
|
||||
}
|
||||
|
||||
public static class MapNested {
|
||||
}
|
||||
|
||||
public static class GenericNested {
|
||||
}
|
||||
|
||||
private List<List<TargetNested>> nestedLists;
|
||||
private Map<String, List<MapNested>> nestedMaps;
|
||||
private GenericHolder<List<GenericNested>> genericHolder;
|
||||
|
||||
public List<List<TargetNested>> getNestedLists() {
|
||||
return nestedLists;
|
||||
}
|
||||
|
||||
public void setNestedLists(List<List<TargetNested>> nestedLists) {
|
||||
this.nestedLists = nestedLists;
|
||||
}
|
||||
|
||||
public Map<String, List<MapNested>> getNestedMaps() {
|
||||
return nestedMaps;
|
||||
}
|
||||
|
||||
public void setNestedMaps(Map<String, List<MapNested>> nestedMaps) {
|
||||
this.nestedMaps = nestedMaps;
|
||||
}
|
||||
|
||||
public GenericHolder<List<GenericNested>> getGenericHolder() {
|
||||
return genericHolder;
|
||||
}
|
||||
|
||||
public void setGenericHolder(GenericHolder<List<GenericNested>> genericHolder) {
|
||||
this.genericHolder = genericHolder;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user