This commit is contained in:
Gunnar Morling 2014-02-28 19:54:47 +01:00
parent 53ff1b7e13
commit 8ddb2a9fb3
7 changed files with 102 additions and 98 deletions

View File

@ -26,7 +26,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.processing.Messager;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
@ -639,7 +638,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
sourceType,
targetType,
targetPropertyName,
dateFormat );
dateFormat
);
property = new PropertyMapping(
parameter.getName(),
@ -709,7 +709,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
sourceElementType,
targetElementType,
null, // there is no targetPropertyName
dateFormat );
dateFormat
);
}
if ( !sourceElementType.isAssignableTo( targetElementType ) && conversion == null &&
@ -766,7 +767,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
keySourceType,
keyTargetType,
null, // there is no targetPropertyName
keyDateFormat );
keyDateFormat
);
}
if ( !keySourceType.isAssignableTo( keyTargetType ) && keyConversion == null && keyMappingMethod == null ) {
@ -814,7 +816,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
valueSourceType,
valueTargetType,
null, // there is no targetPropertyName
valueDateFormat );
valueDateFormat
);
}
if ( !valueSourceType.isAssignableTo( valueTargetType ) && valueConversion == null &&
@ -1043,6 +1046,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
* @param parameterType parameter to match
* @param returnType return type to match
* @param dateFormat used for formatting dates in build in methods that need context information
*
* @return a method reference.
*/
private MethodReference getMappingMethodReferenceBasedOnParameter(SourceMethod mappingMethod,
@ -1069,23 +1073,27 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
// a nested method call can be called. so C = methodY( methodX (A) )
for ( Method methodYCandidate : methodYCandidates ) {
if ( methodYCandidate.getSourceParameters().size() == 1 ) {
methodRefY = getMappingMethodReferenceBasedOnMethod( mappingMethod,
methodRefY = getMappingMethodReferenceBasedOnMethod(
mappingMethod,
mappedElement,
mapperReferences,
methods,
methodYCandidate.getParameters().get( 0 ).getType(),
returnType,
targetPropertyName,
dateFormat );
dateFormat
);
if ( methodRefY != null ) {
MethodReference methodRefX = getMappingMethodReferenceBasedOnMethod( mappingMethod,
MethodReference methodRefX = getMappingMethodReferenceBasedOnMethod(
mappingMethod,
mappedElement,
mapperReferences,
methods,
parameterType,
methodYCandidate.getSourceParameters().get( 0 ).getType(),
targetPropertyName,
dateFormat );
dateFormat
);
if ( methodRefX != null ) {
methodRefY.setMethodRefChild( methodRefX );
break;

View File

@ -21,7 +21,6 @@ package org.mapstruct.ap.test.nestedmethodcall;
import java.util.List;
/**
*
* @author Sjaak Derksen
*/
public class OrderDetailsDto {

View File

@ -23,7 +23,6 @@ import java.util.List;
import javax.xml.bind.JAXBElement;
/**
*
* @author Sjaak Derksen
*/
public class OrderDetailsType {

View File

@ -22,7 +22,6 @@ package org.mapstruct.ap.test.nestedmethodcall;
import java.util.List;
/**
*
* @author Sjaak Derksen
*/
public class OrderDto {

View File

@ -24,7 +24,6 @@ import javax.xml.bind.JAXBElement;
import javax.xml.datatype.XMLGregorianCalendar;
/**
*
* @author Sjaak Derksen
*/
public class OrderType {

View File

@ -22,12 +22,12 @@ package org.mapstruct.ap.test.nestedmethodcall;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.XMLGregorianCalendar;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
/**
*
* @author Sjaak Derksen
*/
@Mapper
@ -36,8 +36,8 @@ public interface SourceTargetMapper {
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
OrderDto sourceToTarget(OrderType source);
OrderDetailsDto detailsToDto(OrderDetailsType source);
OrderDetailsDto detailsToDto(OrderDetailsType source);
@IterableMapping(dateFormat = "dd.MM.yyyy")
List<String> stringListToDateList(List<JAXBElement<XMLGregorianCalendar>> dates);