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;
|
||||
}
|
||||
|
||||
public void setMethodRefChild( MethodReference methodRefChild ) {
|
||||
public void setMethodRefChild(MethodReference methodRefChild) {
|
||||
this.methodRefChild = methodRefChild;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ public class MethodReference extends MappingMethod {
|
||||
@Override
|
||||
public Set<Type> getImportTypes() {
|
||||
Set<Type> imported = super.getImportTypes();
|
||||
if (methodRefChild != null) {
|
||||
if ( methodRefChild != null ) {
|
||||
imported.addAll( methodRefChild.getImportTypes() );
|
||||
}
|
||||
return imported;
|
||||
|
@ -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;
|
||||
@ -628,7 +627,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
conversion
|
||||
);
|
||||
|
||||
if (!isPropertyMappable( property ) ) {
|
||||
if ( !isPropertyMappable( property ) ) {
|
||||
|
||||
// when not mappable, try again with another property mapping method based on parameter only.
|
||||
mappingMethodReference = getMappingMethodReferenceBasedOnParameter(
|
||||
@ -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,
|
||||
@ -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
|
||||
// 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) )
|
||||
for (Method methodYCandidate : methodYCandidates ) {
|
||||
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;
|
||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.test.nestedmethodcall;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderDetailsDto {
|
||||
@ -33,7 +32,7 @@ public class OrderDetailsDto {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName( String name ) {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -41,7 +40,7 @@ public class OrderDetailsDto {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription( List<String> description ) {
|
||||
public void setDescription(List<String> description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderDetailsType {
|
||||
@ -39,7 +38,7 @@ public class OrderDetailsType {
|
||||
this.name = value;
|
||||
}
|
||||
|
||||
public void setDescription( List<JAXBElement<String>> description ) {
|
||||
public void setDescription(List<JAXBElement<String>> description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ package org.mapstruct.ap.test.nestedmethodcall;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderDto {
|
||||
@ -35,7 +34,7 @@ public class OrderDto {
|
||||
return orderNumber;
|
||||
}
|
||||
|
||||
public void setOrderNumber( Long orderNumber ) {
|
||||
public void setOrderNumber(Long orderNumber) {
|
||||
this.orderNumber = orderNumber;
|
||||
}
|
||||
|
||||
@ -43,7 +42,7 @@ public class OrderDto {
|
||||
return orderDetails;
|
||||
}
|
||||
|
||||
public void setOrderDetails( OrderDetailsDto orderDetails ) {
|
||||
public void setOrderDetails(OrderDetailsDto orderDetails) {
|
||||
this.orderDetails = orderDetails;
|
||||
}
|
||||
|
||||
@ -51,7 +50,7 @@ public class OrderDto {
|
||||
return dates;
|
||||
}
|
||||
|
||||
public void setDates( List<String> dates ) {
|
||||
public void setDates(List<String> dates) {
|
||||
this.dates = dates;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.datatype.XMLGregorianCalendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderType {
|
||||
@ -54,7 +53,7 @@ public class OrderType {
|
||||
return dates;
|
||||
}
|
||||
|
||||
public void setDates( List<JAXBElement<XMLGregorianCalendar>> dates ) {
|
||||
public void setDates(List<JAXBElement<XMLGregorianCalendar>> dates) {
|
||||
this.dates = dates;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user