mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#44 Fixing some issues around iterable methods
This commit is contained in:
parent
6e9abacdd6
commit
592371e562
@ -18,10 +18,11 @@
|
||||
*/
|
||||
package org.mapstruct.ap.model;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A {@link MappingMethod} implemented by a {@link Mapper} class which maps one
|
||||
* iterable type to another. The collection elements are mapped either by a
|
||||
* {@link TypeConversion} or another mapping method.
|
||||
* A {@link MappingMethod} implemented by a {@link Mapper} class which maps one iterable type to another. The collection
|
||||
* elements are mapped either by a {@link TypeConversion} or another mapping method.
|
||||
*
|
||||
* @author Gunnar Morling
|
||||
*/
|
||||
@ -46,9 +47,13 @@ public class IterableMappingMethod extends MappingMethod {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MappingMethod {" +
|
||||
"\n elementMappingMethod=" + elementMappingMethod +
|
||||
"\n}";
|
||||
public Set<Type> getImportTypes() {
|
||||
Set<Type> types = super.getImportTypes();
|
||||
|
||||
if ( conversion != null ) {
|
||||
types.addAll( conversion.getImportTypes() );
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,11 @@ public class IterableMapping {
|
||||
private final AnnotationMirror mirror;
|
||||
private final AnnotationValue dateFormatAnnotationValue;
|
||||
|
||||
public static IterableMapping fromIterableMappingPrism(IterableMappingPrism iterableMapping) {
|
||||
public static IterableMapping fromPrism(IterableMappingPrism iterableMapping) {
|
||||
if ( iterableMapping == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new IterableMapping(
|
||||
iterableMapping.dateFormat(),
|
||||
iterableMapping.mirror,
|
||||
|
@ -28,7 +28,9 @@
|
||||
<#if targetType.name == "Iterable" && targetType.packageName == "java.lang">${targetType.iterableImplementationType.name}<#else>${targetType.name}</#if><<@includeModel object=targetType.typeParameters[0]/>> ${targetType.name?uncap_first} = new <#if targetType.iterableImplementationType??>${targetType.iterableImplementationType.name}<#else>${targetType.name}</#if><<@includeModel object=targetType.typeParameters[0]/>>();
|
||||
|
||||
for ( <@includeModel object=sourceType.typeParameters[0]/> ${sourceType.typeParameters[0].name?uncap_first} : ${parameterName} ) {
|
||||
<#if conversion??>
|
||||
<#if elementMappingMethod??>
|
||||
${targetType.name?uncap_first}.add( <@includeModel object=elementMappingMethod input="${sourceType.typeParameters[0].name?uncap_first}"/> );
|
||||
<#else>
|
||||
<#if (conversion.exceptionTypes?size == 0) >
|
||||
${targetType.name?uncap_first}.add( <@includeModel object=conversion/> );
|
||||
<#else>
|
||||
@ -41,8 +43,6 @@
|
||||
}
|
||||
</#list>
|
||||
</#if>
|
||||
<#else>
|
||||
${targetType.name?uncap_first}.add( <@includeModel object=elementMappingMethod input="${sourceType.typeParameters[0].name?uncap_first}"/> );
|
||||
</#if>
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user