-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
The following mapper
@Mapper
public interface WellMapper {
@Mapping( target = "deliveredVerticalPosition.groundLevelPosition.value", source = "wellData.groundLevelPosition")
@Mapping( target = "deliveredVerticalPosition.groundLevelPositioningMethod", source = "wellData.groundLevelPositioningMethod")
void merge( @MappingTarget MonitoringWell target, EventData source );
}Generates the following code:
public class WellMapperImpl implements WellMapper {
@Override
public void merge(MonitoringWell target, EventData source) {
if ( source == null ) {
return;
}
DeliveredVerticalPosition deliveredVerticalPosition = new DeliveredVerticalPosition();
VerticalPosition groundLevelPosition = new VerticalPosition();
deliveredVerticalPosition.setGroundLevelPosition( groundLevelPosition );
target.setDeliveredVerticalPosition( deliveredVerticalPosition );
deliveredVerticalPosition.setGroundLevelPositioningMethod( sourceWellDataGroundLevelPositioningMethod( source ) );
groundLevelPosition.setValue( sourceWellDataGroundLevelPosition( source ) );
}
private String sourceWellDataGroundLevelPositioningMethod(EventData eventData) {
if ( eventData == null ) {
return null;
}
WellData wellData = eventData.getWellData();
if ( wellData == null ) {
return null;
}
String groundLevelPositioningMethod = wellData.getGroundLevelPositioningMethod();
if ( groundLevelPositioningMethod == null ) {
return null;
}
return groundLevelPositioningMethod;
}
private BigDecimal sourceWellDataGroundLevelPosition(EventData eventData) {
if ( eventData == null ) {
return null;
}
WellData wellData = eventData.getWellData();
if ( wellData == null ) {
return null;
}
BigDecimal groundLevelPosition = wellData.getGroundLevelPosition();
if ( groundLevelPosition == null ) {
return null;
}
return groundLevelPosition;
}
}Note that new objects are generated, while I would expect that the nested objects would be obtained from the @MappingTarget