mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1345 cleanup non required isReverse in printing messages
This commit is contained in:
parent
4c1dcc5272
commit
5707f35c85
@ -30,7 +30,6 @@ import org.mapstruct.ap.internal.model.common.Parameter;
|
|||||||
import org.mapstruct.ap.internal.model.common.Type;
|
import org.mapstruct.ap.internal.model.common.Type;
|
||||||
import org.mapstruct.ap.internal.model.common.TypeFactory;
|
import org.mapstruct.ap.internal.model.common.TypeFactory;
|
||||||
import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism;
|
import org.mapstruct.ap.internal.prism.CollectionMappingStrategyPrism;
|
||||||
import org.mapstruct.ap.internal.prism.InheritInverseConfigurationPrism;
|
|
||||||
import org.mapstruct.ap.internal.util.Executables;
|
import org.mapstruct.ap.internal.util.Executables;
|
||||||
import org.mapstruct.ap.internal.util.FormattingMessager;
|
import org.mapstruct.ap.internal.util.FormattingMessager;
|
||||||
import org.mapstruct.ap.internal.util.Message;
|
import org.mapstruct.ap.internal.util.Message;
|
||||||
@ -172,7 +171,7 @@ public class TargetReference {
|
|||||||
|
|
||||||
if ( !foundEntryMatch && errorMessage != null && !isReverse ) {
|
if ( !foundEntryMatch && errorMessage != null && !isReverse ) {
|
||||||
// This is called only for reporting errors
|
// This is called only for reporting errors
|
||||||
errorMessage.report( isReverse );
|
errorMessage.report( );
|
||||||
}
|
}
|
||||||
|
|
||||||
// foundEntryMatch = isValid, errors are handled here, and the BeanMapping uses that to ignore
|
// foundEntryMatch = isValid, errors are handled here, and the BeanMapping uses that to ignore
|
||||||
@ -375,20 +374,14 @@ public class TargetReference {
|
|||||||
this.messager = messager;
|
this.messager = messager;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract void report(boolean isReverse);
|
abstract void report();
|
||||||
|
|
||||||
protected void printErrorMessage(Message message, boolean isReverse, Object... args) {
|
protected void printErrorMessage(Message message, Object... args) {
|
||||||
Object[] errorArgs = new Object[args.length + 2];
|
Object[] errorArgs = new Object[args.length + 2];
|
||||||
errorArgs[0] = mapping.getTargetName();
|
errorArgs[0] = mapping.getTargetName();
|
||||||
errorArgs[1] = method.getResultType();
|
errorArgs[1] = method.getResultType();
|
||||||
System.arraycopy( args, 0, errorArgs, 2, args.length );
|
System.arraycopy( args, 0, errorArgs, 2, args.length );
|
||||||
AnnotationMirror annotationMirror = mapping.getMirror();
|
AnnotationMirror annotationMirror = mapping.getMirror();
|
||||||
if ( isReverse ) {
|
|
||||||
InheritInverseConfigurationPrism reversePrism = InheritInverseConfigurationPrism.getInstanceOn(
|
|
||||||
method.getExecutable() );
|
|
||||||
|
|
||||||
annotationMirror = reversePrism == null ? annotationMirror : reversePrism.mirror;
|
|
||||||
}
|
|
||||||
messager.printMessage( method.getExecutable(), annotationMirror, mapping.getSourceAnnotationValue(),
|
messager.printMessage( method.getExecutable(), annotationMirror, mapping.getSourceAnnotationValue(),
|
||||||
message, errorArgs
|
message, errorArgs
|
||||||
);
|
);
|
||||||
@ -402,8 +395,8 @@ public class TargetReference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void report(boolean isReverse) {
|
public void report() {
|
||||||
printErrorMessage( Message.BEANMAPPING_PROPERTY_HAS_NO_WRITE_ACCESSOR_IN_RESULTTYPE, isReverse );
|
printErrorMessage( Message.BEANMAPPING_PROPERTY_HAS_NO_WRITE_ACCESSOR_IN_RESULTTYPE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,22 +415,15 @@ public class TargetReference {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void report(boolean isReverse) {
|
public void report() {
|
||||||
|
|
||||||
Set<String> readAccessors = nextType.getPropertyReadAccessors().keySet();
|
Set<String> readAccessors = nextType.getPropertyReadAccessors().keySet();
|
||||||
String mostSimilarProperty = Strings.getMostSimilarWord(
|
String mostSimilarProperty = Strings.getMostSimilarWord( entryNames[index], readAccessors );
|
||||||
entryNames[index],
|
|
||||||
readAccessors
|
|
||||||
);
|
|
||||||
|
|
||||||
List<String> elements = new ArrayList<String>( Arrays.asList( entryNames ).subList( 0, index ) );
|
List<String> elements = new ArrayList<String>( Arrays.asList( entryNames ).subList( 0, index ) );
|
||||||
elements.add( mostSimilarProperty );
|
elements.add( mostSimilarProperty );
|
||||||
|
|
||||||
printErrorMessage(
|
printErrorMessage( Message.BEANMAPPING_UNKNOWN_PROPERTY_IN_RESULTTYPE, Strings.join( elements, "." ) );
|
||||||
Message.BEANMAPPING_UNKNOWN_PROPERTY_IN_RESULTTYPE,
|
|
||||||
isReverse,
|
|
||||||
Strings.join( elements, "." )
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user