mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#10 Making sure error is raised in case property can't be reverse-mapped
This commit is contained in:
parent
0c6c28f13c
commit
3036b2f2a7
@ -236,13 +236,16 @@ public class MapperGenerationVisitor extends ElementKindVisitor6<Void, Void> {
|
||||
}
|
||||
|
||||
private void reportErrorIfPropertyCanNotBeMapped(Method method, Method reverseMethod, MappedProperty property, Method propertyMappingMethod, Method reversePropertyMappingMethod, Conversion conversion) {
|
||||
if ( property.getSourceType().equals( property.getTargetType() ) ||
|
||||
if ( property.getSourceType().equals( property.getTargetType() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
//no mapping method nor conversion nor collection with default implementation
|
||||
if ( !(
|
||||
propertyMappingMethod != null ||
|
||||
conversion != null ||
|
||||
( property.getTargetType().isCollectionType() && property.getTargetType()
|
||||
.getCollectionImplementationType() != null ) ) {
|
||||
return;
|
||||
}
|
||||
.getCollectionImplementationType() != null ) ) ) {
|
||||
|
||||
reportError(
|
||||
String.format(
|
||||
@ -254,16 +257,17 @@ public class MapperGenerationVisitor extends ElementKindVisitor6<Void, Void> {
|
||||
),
|
||||
method.getExecutable()
|
||||
);
|
||||
}
|
||||
|
||||
mappingErroneous = true;
|
||||
if ( reverseMethod == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( reverseMethod == null ||
|
||||
if ( !(
|
||||
reversePropertyMappingMethod != null ||
|
||||
conversion != null ||
|
||||
( property.getSourceType().isCollectionType() && property.getSourceType()
|
||||
.getCollectionImplementationType() == null ) ) {
|
||||
return;
|
||||
}
|
||||
.getCollectionImplementationType() != null ) ) ) {
|
||||
|
||||
reportError(
|
||||
String.format(
|
||||
@ -276,6 +280,7 @@ public class MapperGenerationVisitor extends ElementKindVisitor6<Void, Void> {
|
||||
reverseMethod.getExecutable()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private String getIterableConversionString(Conversions conversions, Type sourceElementType, Type targetElementType, boolean isToConversion) {
|
||||
Conversion conversion = conversions.getConversion( sourceElementType, targetElementType );
|
||||
|
Loading…
x
Reference in New Issue
Block a user