mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#134 Formatting
This commit is contained in:
parent
53ff1b7e13
commit
8ddb2a9fb3
@ -72,7 +72,7 @@ public class MethodReference extends MappingMethod {
|
|||||||
return contextParam;
|
return contextParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodRefChild( MethodReference methodRefChild ) {
|
public void setMethodRefChild(MethodReference methodRefChild) {
|
||||||
this.methodRefChild = methodRefChild;
|
this.methodRefChild = methodRefChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ public class MethodReference extends MappingMethod {
|
|||||||
@Override
|
@Override
|
||||||
public Set<Type> getImportTypes() {
|
public Set<Type> getImportTypes() {
|
||||||
Set<Type> imported = super.getImportTypes();
|
Set<Type> imported = super.getImportTypes();
|
||||||
if (methodRefChild != null) {
|
if ( methodRefChild != null ) {
|
||||||
imported.addAll( methodRefChild.getImportTypes() );
|
imported.addAll( methodRefChild.getImportTypes() );
|
||||||
}
|
}
|
||||||
return imported;
|
return imported;
|
||||||
|
@ -26,7 +26,6 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.processing.Messager;
|
import javax.annotation.processing.Messager;
|
||||||
import javax.lang.model.element.Element;
|
import javax.lang.model.element.Element;
|
||||||
import javax.lang.model.element.ExecutableElement;
|
import javax.lang.model.element.ExecutableElement;
|
||||||
@ -628,7 +627,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
conversion
|
conversion
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!isPropertyMappable( property ) ) {
|
if ( !isPropertyMappable( property ) ) {
|
||||||
|
|
||||||
// when not mappable, try again with another property mapping method based on parameter only.
|
// when not mappable, try again with another property mapping method based on parameter only.
|
||||||
mappingMethodReference = getMappingMethodReferenceBasedOnParameter(
|
mappingMethodReference = getMappingMethodReferenceBasedOnParameter(
|
||||||
@ -639,7 +638,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
sourceType,
|
sourceType,
|
||||||
targetType,
|
targetType,
|
||||||
targetPropertyName,
|
targetPropertyName,
|
||||||
dateFormat );
|
dateFormat
|
||||||
|
);
|
||||||
|
|
||||||
property = new PropertyMapping(
|
property = new PropertyMapping(
|
||||||
parameter.getName(),
|
parameter.getName(),
|
||||||
@ -709,7 +709,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
sourceElementType,
|
sourceElementType,
|
||||||
targetElementType,
|
targetElementType,
|
||||||
null, // there is no targetPropertyName
|
null, // there is no targetPropertyName
|
||||||
dateFormat );
|
dateFormat
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !sourceElementType.isAssignableTo( targetElementType ) && conversion == null &&
|
if ( !sourceElementType.isAssignableTo( targetElementType ) && conversion == null &&
|
||||||
@ -766,7 +767,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
keySourceType,
|
keySourceType,
|
||||||
keyTargetType,
|
keyTargetType,
|
||||||
null, // there is no targetPropertyName
|
null, // there is no targetPropertyName
|
||||||
keyDateFormat );
|
keyDateFormat
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !keySourceType.isAssignableTo( keyTargetType ) && keyConversion == null && keyMappingMethod == null ) {
|
if ( !keySourceType.isAssignableTo( keyTargetType ) && keyConversion == null && keyMappingMethod == null ) {
|
||||||
@ -814,7 +816,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
valueSourceType,
|
valueSourceType,
|
||||||
valueTargetType,
|
valueTargetType,
|
||||||
null, // there is no targetPropertyName
|
null, // there is no targetPropertyName
|
||||||
valueDateFormat );
|
valueDateFormat
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !valueSourceType.isAssignableTo( valueTargetType ) && valueConversion == null &&
|
if ( !valueSourceType.isAssignableTo( valueTargetType ) && valueConversion == null &&
|
||||||
@ -1043,6 +1046,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
* @param parameterType parameter to match
|
* @param parameterType parameter to match
|
||||||
* @param returnType return type to match
|
* @param returnType return type to match
|
||||||
* @param dateFormat used for formatting dates in build in methods that need context information
|
* @param dateFormat used for formatting dates in build in methods that need context information
|
||||||
|
*
|
||||||
* @return a method reference.
|
* @return a method reference.
|
||||||
*/
|
*/
|
||||||
private MethodReference getMappingMethodReferenceBasedOnParameter(SourceMethod mappingMethod,
|
private MethodReference getMappingMethodReferenceBasedOnParameter(SourceMethod mappingMethod,
|
||||||
@ -1067,25 +1071,29 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
// For each of the candidates, we need to look if there's a methodY, either
|
// For each of the candidates, we need to look if there's a methodY, either
|
||||||
// sourceMethod or builtIn that fits the signature B to C. Only then there is a match. If we have a match
|
// sourceMethod or builtIn that fits the signature B to C. Only then there is a match. If we have a match
|
||||||
// a nested method call can be called. so C = methodY( methodX (A) )
|
// a nested method call can be called. so C = methodY( methodX (A) )
|
||||||
for (Method methodYCandidate : methodYCandidates ) {
|
for ( Method methodYCandidate : methodYCandidates ) {
|
||||||
if ( methodYCandidate.getSourceParameters().size() == 1 ) {
|
if ( methodYCandidate.getSourceParameters().size() == 1 ) {
|
||||||
methodRefY = getMappingMethodReferenceBasedOnMethod( mappingMethod,
|
methodRefY = getMappingMethodReferenceBasedOnMethod(
|
||||||
|
mappingMethod,
|
||||||
mappedElement,
|
mappedElement,
|
||||||
mapperReferences,
|
mapperReferences,
|
||||||
methods,
|
methods,
|
||||||
methodYCandidate.getParameters().get( 0 ).getType(),
|
methodYCandidate.getParameters().get( 0 ).getType(),
|
||||||
returnType,
|
returnType,
|
||||||
targetPropertyName,
|
targetPropertyName,
|
||||||
dateFormat );
|
dateFormat
|
||||||
|
);
|
||||||
if ( methodRefY != null ) {
|
if ( methodRefY != null ) {
|
||||||
MethodReference methodRefX = getMappingMethodReferenceBasedOnMethod( mappingMethod,
|
MethodReference methodRefX = getMappingMethodReferenceBasedOnMethod(
|
||||||
|
mappingMethod,
|
||||||
mappedElement,
|
mappedElement,
|
||||||
mapperReferences,
|
mapperReferences,
|
||||||
methods,
|
methods,
|
||||||
parameterType,
|
parameterType,
|
||||||
methodYCandidate.getSourceParameters().get( 0 ).getType(),
|
methodYCandidate.getSourceParameters().get( 0 ).getType(),
|
||||||
targetPropertyName,
|
targetPropertyName,
|
||||||
dateFormat );
|
dateFormat
|
||||||
|
);
|
||||||
if ( methodRefX != null ) {
|
if ( methodRefX != null ) {
|
||||||
methodRefY.setMethodRefChild( methodRefX );
|
methodRefY.setMethodRefChild( methodRefX );
|
||||||
break;
|
break;
|
||||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.test.nestedmethodcall;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class OrderDetailsDto {
|
public class OrderDetailsDto {
|
||||||
@ -33,7 +32,7 @@ public class OrderDetailsDto {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName( String name ) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +40,7 @@ public class OrderDetailsDto {
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription( List<String> description ) {
|
public void setDescription(List<String> description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class OrderDetailsType {
|
public class OrderDetailsType {
|
||||||
@ -39,7 +38,7 @@ public class OrderDetailsType {
|
|||||||
this.name = value;
|
this.name = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription( List<JAXBElement<String>> description ) {
|
public void setDescription(List<JAXBElement<String>> description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ package org.mapstruct.ap.test.nestedmethodcall;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class OrderDto {
|
public class OrderDto {
|
||||||
@ -35,7 +34,7 @@ public class OrderDto {
|
|||||||
return orderNumber;
|
return orderNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderNumber( Long orderNumber ) {
|
public void setOrderNumber(Long orderNumber) {
|
||||||
this.orderNumber = orderNumber;
|
this.orderNumber = orderNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ public class OrderDto {
|
|||||||
return orderDetails;
|
return orderDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrderDetails( OrderDetailsDto orderDetails ) {
|
public void setOrderDetails(OrderDetailsDto orderDetails) {
|
||||||
this.orderDetails = orderDetails;
|
this.orderDetails = orderDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +50,7 @@ public class OrderDto {
|
|||||||
return dates;
|
return dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDates( List<String> dates ) {
|
public void setDates(List<String> dates) {
|
||||||
this.dates = dates;
|
this.dates = dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@ import javax.xml.bind.JAXBElement;
|
|||||||
import javax.xml.datatype.XMLGregorianCalendar;
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class OrderType {
|
public class OrderType {
|
||||||
@ -54,7 +53,7 @@ public class OrderType {
|
|||||||
return dates;
|
return dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDates( List<JAXBElement<XMLGregorianCalendar>> dates ) {
|
public void setDates(List<JAXBElement<XMLGregorianCalendar>> dates) {
|
||||||
this.dates = dates;
|
this.dates = dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ package org.mapstruct.ap.test.nestedmethodcall;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.datatype.XMLGregorianCalendar;
|
import javax.xml.datatype.XMLGregorianCalendar;
|
||||||
|
|
||||||
import org.mapstruct.IterableMapping;
|
import org.mapstruct.IterableMapping;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
@ -36,8 +36,8 @@ public interface SourceTargetMapper {
|
|||||||
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
|
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
|
||||||
|
|
||||||
OrderDto sourceToTarget(OrderType source);
|
OrderDto sourceToTarget(OrderType source);
|
||||||
OrderDetailsDto detailsToDto(OrderDetailsType source);
|
|
||||||
|
|
||||||
|
OrderDetailsDto detailsToDto(OrderDetailsType source);
|
||||||
|
|
||||||
@IterableMapping(dateFormat = "dd.MM.yyyy")
|
@IterableMapping(dateFormat = "dd.MM.yyyy")
|
||||||
List<String> stringListToDateList(List<JAXBElement<XMLGregorianCalendar>> dates);
|
List<String> stringListToDateList(List<JAXBElement<XMLGregorianCalendar>> dates);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user