mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#339 Uppercase for ENUM in messages, moving Diagnostic.Kind to Message
This commit is contained in:
parent
580d7869fd
commit
b83c430758
@ -120,10 +120,9 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
if ( beanMapping != null && beanMapping.getResultType() != null ) {
|
||||
resultType = ctx.getTypeFactory().getType( beanMapping.getResultType() );
|
||||
if ( !resultType.isAssignableTo( method.getResultType() ) ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
beanMappingPrism.mirror,
|
||||
Message.beanmapping_notassignable, resultType, method.getResultType());
|
||||
Message.BEANMAPPING_NOT_ASSIGNABLE, resultType, method.getResultType());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,11 +153,10 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
// fetch the target property
|
||||
ExecutableElement targetProperty = unprocessedTargetProperties.get( mapping.getTargetName() );
|
||||
if ( targetProperty == null ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
mapping.getMirror(),
|
||||
mapping.getSourceAnnotationValue(),
|
||||
Message.beanmapping_unknownpropertyinreturntype,
|
||||
Message.BEANMAPPING_UNKNOWN_PROPERTY_IN_RETURNTYPE,
|
||||
mapping.getTargetName()
|
||||
);
|
||||
errorOccurred = true;
|
||||
@ -310,9 +308,8 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
|
||||
if ( propertyMapping != null && newPropertyMapping != null ) {
|
||||
// TODO improve error message
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.beanmapping_severalpossiblesources,
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
Message.BEANMAPPING_SEVERAL_POSSIBLE_SOURCES,
|
||||
targetProperty.getKey()
|
||||
);
|
||||
break;
|
||||
@ -389,9 +386,8 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
}
|
||||
// Should never really happen
|
||||
else {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.beanmapping_severalpossibletargetaccessors,
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
Message.BEANMAPPING_SEVERAL_POSSIBLE_TARGET_ACCESSORS,
|
||||
sourcePropertyName
|
||||
);
|
||||
|
||||
@ -430,9 +426,11 @@ public class BeanMappingMethod extends MappingMethod {
|
||||
|
||||
if ( !unprocessedTargetProperties.isEmpty() && unmappedTargetPolicy.requiresReport() ) {
|
||||
|
||||
ctx.getMessager().printMessage( unmappedTargetPolicy.getDiagnosticKind(),
|
||||
method.getExecutable(),
|
||||
Message.beanmapping_unmappedtargets,
|
||||
Message msg = unmappedTargetPolicy.getDiagnosticKind() == Diagnostic.Kind.ERROR ?
|
||||
Message.BEANMAPPING_UNMAPPED_TARGETS_ERROR : Message.BEANMAPPING_UNMAPPED_TARGETS_WARNING;
|
||||
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
msg,
|
||||
MessageFormat.format(
|
||||
"{0,choice,1#property|1<properties}: \"{1}\"",
|
||||
unprocessedTargetProperties.size(),
|
||||
|
@ -20,7 +20,6 @@ package org.mapstruct.ap.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.model.common.Parameter;
|
||||
import org.mapstruct.ap.model.source.EnumMapping;
|
||||
@ -85,9 +84,8 @@ public class EnumMappingMethod extends MappingMethod {
|
||||
for ( Mapping mapping : mappedConstants ) {
|
||||
targetConstants.add( mapping.getTargetName() );
|
||||
}
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.enummapping_multipletargets,
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
Message.ENUMMAPPING_MULTIPLE_TARGETS,
|
||||
enumConstant,
|
||||
Strings.join( targetConstants, ", " )
|
||||
);
|
||||
@ -108,38 +106,34 @@ public class EnumMappingMethod extends MappingMethod {
|
||||
for ( Mapping mappedConstant : mappedConstants ) {
|
||||
|
||||
if ( mappedConstant.getSourceName() == null ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
mappedConstant.getMirror(),
|
||||
Message.enummapping_undefinedsource
|
||||
Message.ENUMMAPPING_UNDEFINED_SOURCE
|
||||
);
|
||||
foundIncorrectMapping = true;
|
||||
}
|
||||
else if ( !sourceEnumConstants.contains( mappedConstant.getSourceName() ) ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
mappedConstant.getMirror(),
|
||||
mappedConstant.getSourceAnnotationValue(),
|
||||
Message.enummapping_nonexistingconstant,
|
||||
Message.ENUMMAPPING_NON_EXISTING_CONSTANT,
|
||||
mappedConstant.getSourceName(),
|
||||
method.getSourceParameters().iterator().next().getType()
|
||||
);
|
||||
foundIncorrectMapping = true;
|
||||
}
|
||||
if ( mappedConstant.getTargetName() == null ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
mappedConstant.getMirror(),
|
||||
Message.enummapping_undefinedtarget
|
||||
Message.ENUMMAPPING_UNDEFINED_TARGET
|
||||
);
|
||||
foundIncorrectMapping = true;
|
||||
}
|
||||
else if ( !targetEnumConstants.contains( mappedConstant.getTargetName() ) ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
mappedConstant.getMirror(),
|
||||
mappedConstant.getTargetAnnotationValue(),
|
||||
Message.enummapping_nonexistingconstant,
|
||||
Message.ENUMMAPPING_NON_EXISTING_CONSTANT,
|
||||
mappedConstant.getTargetName(),
|
||||
method.getReturnType()
|
||||
);
|
||||
@ -167,9 +161,8 @@ public class EnumMappingMethod extends MappingMethod {
|
||||
}
|
||||
|
||||
if ( !unmappedSourceEnumConstants.isEmpty() ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.enummapping_unmappedtargets,
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
Message.ENUMMAPPING_UNMAPPED_TARGETS,
|
||||
Strings.join( unmappedSourceEnumConstants, ", " )
|
||||
);
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.model.assignment.Assignment;
|
||||
import org.mapstruct.ap.model.assignment.LocalVarWrapper;
|
||||
@ -112,8 +111,7 @@ public class IterableMappingMethod extends MappingMethod {
|
||||
);
|
||||
|
||||
if ( assignment == null ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR, method.getExecutable(),
|
||||
Message.iterablemapping_mappingnotfound );
|
||||
ctx.getMessager().printMessage( method.getExecutable(), Message.ITERABLEMAPPING_MAPPING_NOT_FOUND );
|
||||
}
|
||||
|
||||
// target accessor is setter, so decorate assignment as setter
|
||||
|
@ -21,7 +21,6 @@ package org.mapstruct.ap.model;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.model.assignment.Assignment;
|
||||
import org.mapstruct.ap.model.assignment.LocalVarWrapper;
|
||||
@ -120,8 +119,7 @@ public class MapMappingMethod extends MappingMethod {
|
||||
);
|
||||
|
||||
if ( keyAssignment == null ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR, method.getExecutable(),
|
||||
Message.mapmapping_key_mappingnotfound );
|
||||
ctx.getMessager().printMessage( method.getExecutable(), Message.MAPMAPPING_KEY_MAPPING_NOT_FOUND );
|
||||
}
|
||||
|
||||
// find mapping method or conversion for value
|
||||
@ -141,8 +139,7 @@ public class MapMappingMethod extends MappingMethod {
|
||||
);
|
||||
|
||||
if ( valueAssignment == null ) {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR, method.getExecutable(),
|
||||
Message.mapmapping_value_mappingnotfound );
|
||||
ctx.getMessager().printMessage( method.getExecutable(), Message.MAPMAPPING_VALUE_MAPPING_NOT_FOUND );
|
||||
}
|
||||
|
||||
// mapNullToDefault
|
||||
|
@ -23,7 +23,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.model.assignment.AdderWrapper;
|
||||
import org.mapstruct.ap.model.assignment.ArrayCopyWrapper;
|
||||
@ -172,9 +171,8 @@ public class PropertyMapping extends ModelElement {
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.propertymapping_mappingnotfound,
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
Message.PROPERTYMAPPING_MAPPING_NOT_FOUND,
|
||||
sourceElement,
|
||||
targetType,
|
||||
targetPropertyName,
|
||||
@ -531,9 +529,8 @@ public class PropertyMapping extends ModelElement {
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctx.getMessager().printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.constantmapping_mappingnotfound,
|
||||
ctx.getMessager().printMessage( method.getExecutable(),
|
||||
Message.CONSTANTMAPPING_MAPPING_NOT_FOUND,
|
||||
sourceType,
|
||||
constantExpression,
|
||||
targetType,
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.mapstruct.ap.model.common;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
import org.mapstruct.ap.util.Message;
|
||||
import org.mapstruct.ap.util.FormattingMessager;
|
||||
|
||||
@ -49,7 +48,7 @@ final class DateFormatValidationResult {
|
||||
}
|
||||
|
||||
public void printErrorMessage(FormattingMessager messager) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR, validationInfo, validationInfoArgs );
|
||||
messager.printMessage( validationInfo, validationInfoArgs );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ final class DateFormatValidatorFactory {
|
||||
dateFormatValidator = new DateFormatValidator() {
|
||||
@Override
|
||||
public DateFormatValidationResult validate(String dateFormat) {
|
||||
return new DateFormatValidationResult( true, Message.general_unsupporteddateformatcheck,
|
||||
return new DateFormatValidationResult( true, Message.GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK,
|
||||
sourceType, targetType );
|
||||
}
|
||||
};
|
||||
@ -179,10 +179,10 @@ final class DateFormatValidatorFactory {
|
||||
}
|
||||
|
||||
private static DateFormatValidationResult validDateFormat(String dateFormat) {
|
||||
return new DateFormatValidationResult( true, Message.general_validdate, dateFormat );
|
||||
return new DateFormatValidationResult( true, Message.GENERAL_VALID_DATE, dateFormat );
|
||||
}
|
||||
|
||||
private static DateFormatValidationResult invalidDateFormat(String dateFormat, Throwable e) {
|
||||
return new DateFormatValidationResult( false, Message.general_invaliddate, dateFormat, e.getMessage() );
|
||||
return new DateFormatValidationResult( false, Message.GENERAL_INVALID_DATE, dateFormat, e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ import org.mapstruct.ap.util.FormattingMessager;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
import org.mapstruct.ap.prism.BeanMappingPrism;
|
||||
import org.mapstruct.ap.util.Message;
|
||||
|
||||
@ -46,7 +45,7 @@ public class BeanMapping {
|
||||
|
||||
boolean resultTypeIsDefined = !TypeKind.VOID.equals( beanMapping.resultType().getKind() );
|
||||
if ( !resultTypeIsDefined && beanMapping.qualifiedBy().isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR, method, Message.beanmapping_noelements );
|
||||
messager.printMessage( method, Message.BEANMAPPING_NO_ELEMENTS );
|
||||
}
|
||||
|
||||
return new BeanMapping(
|
||||
|
@ -25,7 +25,6 @@ import javax.lang.model.element.AnnotationValue;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.prism.IterableMappingPrism;
|
||||
import org.mapstruct.ap.util.Message;
|
||||
@ -53,7 +52,7 @@ public class IterableMapping {
|
||||
if ( !elementTargetTypeIsDefined
|
||||
&& iterableMapping.dateFormat().isEmpty()
|
||||
&& iterableMapping.qualifiedBy().isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR, method, Message.iterablemapping_noelements );
|
||||
messager.printMessage( method, Message.ITERABLEMAPPING_NO_ELEMENTS );
|
||||
}
|
||||
|
||||
return new IterableMapping(
|
||||
|
@ -24,7 +24,6 @@ import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.prism.MapMappingPrism;
|
||||
import org.mapstruct.ap.util.Message;
|
||||
@ -58,7 +57,7 @@ public class MapMapping {
|
||||
&& mapMapping.valueQualifiedBy().isEmpty()
|
||||
&& !keyTargetTypeIsDefined
|
||||
&& !valueTargetTypeIsDefined ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR, method, Message.mapmapping_noelements );
|
||||
messager.printMessage( method, Message.MAPMAPPING_NO_ELEMENTS );
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,8 +32,6 @@ import javax.lang.model.element.ExecutableElement;
|
||||
import javax.lang.model.type.DeclaredType;
|
||||
import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import org.mapstruct.ap.model.common.TypeFactory;
|
||||
import org.mapstruct.ap.prism.CollectionMappingStrategyPrism;
|
||||
@ -82,11 +80,7 @@ public class Mapping {
|
||||
mappingsOfProperty.add( mapping );
|
||||
|
||||
if ( mappingsOfProperty.size() > 1 && !isEnumType( method.getReturnType() ) ) {
|
||||
messager.printMessage( Kind.ERROR,
|
||||
method,
|
||||
Message.propertymapping_duplicatetargets,
|
||||
mappingPrism.target()
|
||||
);
|
||||
messager.printMessage( method, Message.PROPERTYMAPPING_DUPLICATE_TARGETS, mappingPrism.target() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,34 +92,24 @@ public class Mapping {
|
||||
FormattingMessager messager) {
|
||||
|
||||
if ( mappingPrism.target().isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
element,
|
||||
messager.printMessage( element,
|
||||
mappingPrism.mirror,
|
||||
mappingPrism.values.target(),
|
||||
Message.propertymapping_emptytarget
|
||||
Message.PROPERTYMAPPING_EMPTY_TARGET
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( !mappingPrism.source().isEmpty() && !mappingPrism.constant().isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
element,
|
||||
Message.propertymapping_sourceandconstantbothdefined
|
||||
);
|
||||
messager.printMessage( element, Message.PROPERTYMAPPING_SOURCE_AND_CONSTANT_BOTH_DEFINED );
|
||||
return null;
|
||||
}
|
||||
else if ( !mappingPrism.source().isEmpty() && !mappingPrism.expression().isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
element,
|
||||
Message.propertymapping_sourceandexpressionbothdefined
|
||||
);
|
||||
messager.printMessage( element, Message.PROPERTYMAPPING_SOURCE_AND_EXPRESSION_BOTH_DEFINED );
|
||||
return null;
|
||||
}
|
||||
else if ( !mappingPrism.expression().isEmpty() && !mappingPrism.constant().isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
element,
|
||||
Message.propertymapping_expressionandconstantbothdefined
|
||||
);
|
||||
messager.printMessage( element, Message.PROPERTYMAPPING_EXPRESSION_AND_CONSTANT_BOTH_DEFINED );
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -180,12 +164,8 @@ public class Mapping {
|
||||
Matcher javaExpressionMatcher = JAVA_EXPRESSION.matcher( mappingPrism.expression() );
|
||||
|
||||
if ( !javaExpressionMatcher.matches() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
element,
|
||||
mappingPrism.mirror,
|
||||
mappingPrism.values.expression(),
|
||||
Message.propertymapping_invalidexpression
|
||||
);
|
||||
messager.printMessage( element, mappingPrism.mirror, mappingPrism.values.expression(),
|
||||
Message.PROPERTYMAPPING_INVALID_EXPRESSION );
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -295,11 +275,8 @@ public class Mapping {
|
||||
if ( sourceReference != null && sourceReference.getPropertyEntries().isEmpty() ) {
|
||||
// parameter mapping only, apparently the @InheritReverseConfiguration is intentional
|
||||
// but erroneous. Lets raise an error to warn.
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.propertymapping_reversalproblem,
|
||||
sourceReference.getParameter()
|
||||
);
|
||||
messager.printMessage( method.getExecutable(), Message.PROPERTYMAPPING_REVERSAL_PROBLEM,
|
||||
sourceReference.getParameter() );
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@ import java.util.List;
|
||||
|
||||
import org.mapstruct.ap.util.FormattingMessager;
|
||||
import javax.lang.model.element.ExecutableElement;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.model.common.Parameter;
|
||||
import org.mapstruct.ap.model.common.Type;
|
||||
@ -115,7 +114,7 @@ public class SourceReference {
|
||||
String sourceParameterName = segments[0];
|
||||
parameter = method.getSourceParameter( sourceParameterName );
|
||||
if ( parameter == null ) {
|
||||
reportMappingError( Message.propertymapping_invalidparametername, sourceParameterName );
|
||||
reportMappingError( Message.PROPERTYMAPPING_INVALID_PARAMETER_NAME, sourceParameterName );
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
@ -155,15 +154,11 @@ public class SourceReference {
|
||||
if ( !foundEntryMatch ) {
|
||||
|
||||
if ( parameter != null ) {
|
||||
reportMappingError( Message.propertymapping_nopropertyinparameter,
|
||||
parameter.getName(),
|
||||
Strings.join( Arrays.asList( sourcePropertyNames ), "." )
|
||||
);
|
||||
reportMappingError( Message.PROPERTYMAPPING_NO_PROPERTY_IN_PARAMETER, parameter.getName(),
|
||||
Strings.join( Arrays.asList( sourcePropertyNames ), "." ) );
|
||||
}
|
||||
else {
|
||||
reportMappingError( Message.propertymapping_invalidpropertyname,
|
||||
mapping.getSourceName()
|
||||
);
|
||||
reportMappingError( Message.PROPERTYMAPPING_INVALID_PROPERTY_NAME, mapping.getSourceName() );
|
||||
}
|
||||
isValid = false;
|
||||
}
|
||||
@ -193,14 +188,8 @@ public class SourceReference {
|
||||
}
|
||||
|
||||
private void reportMappingError(Message msg, Object... objects) {
|
||||
messager.printMessage(
|
||||
Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
mapping.getMirror(),
|
||||
mapping.getSourceAnnotationValue(),
|
||||
msg,
|
||||
objects
|
||||
);
|
||||
messager.printMessage( method.getExecutable(), mapping.getMirror(), mapping.getSourceAnnotationValue(),
|
||||
msg, objects );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,38 +109,38 @@ public class DefaultModelElementProcessorContext implements ProcessorContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Kind kind, Message msg, Object... args) {
|
||||
public void printMessage(Message msg, Object... args) {
|
||||
String message = String.format( msg.getDescription(), args );
|
||||
delegate.printMessage( kind, message);
|
||||
if ( kind == Kind.ERROR ) {
|
||||
delegate.printMessage( msg.getDiagnosticKind(), message);
|
||||
if ( msg.getDiagnosticKind() == Kind.ERROR ) {
|
||||
isErroneous = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Kind kind, Element e, Message msg, Object... args) {
|
||||
public void printMessage(Element e, Message msg, Object... args) {
|
||||
String message = String.format( msg.getDescription(), args );
|
||||
delegate.printMessage( kind, message, e );
|
||||
if ( kind == Kind.ERROR ) {
|
||||
delegate.printMessage( msg.getDiagnosticKind(), message, e );
|
||||
if ( msg.getDiagnosticKind() == Kind.ERROR ) {
|
||||
isErroneous = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Kind kind, Element e, AnnotationMirror a, Message msg, Object... args) {
|
||||
public void printMessage(Element e, AnnotationMirror a, Message msg, Object... args) {
|
||||
String message = String.format( msg.getDescription(), args );
|
||||
delegate.printMessage( kind, message, e, a );
|
||||
if ( kind == Kind.ERROR ) {
|
||||
delegate.printMessage( msg.getDiagnosticKind(), message, e, a );
|
||||
if ( msg.getDiagnosticKind() == Kind.ERROR ) {
|
||||
isErroneous = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Kind kind, Element e, AnnotationMirror a, AnnotationValue v, Message msg,
|
||||
public void printMessage(Element e, AnnotationMirror a, AnnotationValue v, Message msg,
|
||||
Object... args) {
|
||||
String message = String.format( msg.getDescription(), args );
|
||||
delegate.printMessage( kind, message, e, a, v );
|
||||
if ( kind == Kind.ERROR ) {
|
||||
delegate.printMessage( msg.getDiagnosticKind(), message, e, a, v );
|
||||
if ( msg.getDiagnosticKind() == Kind.ERROR ) {
|
||||
isErroneous = true;
|
||||
}
|
||||
}
|
||||
|
@ -32,8 +32,6 @@ import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.util.ElementFilter;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.util.Types;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import org.mapstruct.ap.model.BeanMappingMethod;
|
||||
import org.mapstruct.ap.model.Decorator;
|
||||
@ -166,7 +164,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
TypeElement decoratorElement = (TypeElement) typeUtils.asElement( decoratorPrism.value() );
|
||||
|
||||
if ( !typeUtils.isAssignable( decoratorElement.asType(), element.asType() ) ) {
|
||||
messager.printMessage( Kind.ERROR, element, decoratorPrism.mirror, Message.decorator_nosubtype);
|
||||
messager.printMessage( element, decoratorPrism.mirror, Message.DECORATOR_NO_SUBTYPE);
|
||||
}
|
||||
|
||||
List<MappingMethod> mappingMethods = new ArrayList<MappingMethod>( methods.size() );
|
||||
@ -204,7 +202,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
}
|
||||
|
||||
if ( !hasDelegateConstructor && !hasDefaultConstructor ) {
|
||||
messager.printMessage( Kind.ERROR, element, decoratorPrism.mirror, Message.decorator_constructor );
|
||||
messager.printMessage( element, decoratorPrism.mirror, Message.DECORATOR_CONSTRUCTOR );
|
||||
}
|
||||
|
||||
return Decorator.getInstance(
|
||||
@ -360,11 +358,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
if ( method.getReturnType().getTypeMirror().getKind() != TypeKind.VOID &&
|
||||
method.getReturnType().isInterface() &&
|
||||
method.getReturnType().getImplementationType() == null ) {
|
||||
messager.printMessage( Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
Message.general_noimplementation,
|
||||
method.getReturnType()
|
||||
);
|
||||
messager.printMessage( method.getExecutable(), Message.GENERAL_NO_IMPLEMENTATION, method.getReturnType() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,11 +500,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
method.getExecutable()
|
||||
);
|
||||
if ( reversePrism != null ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritconfiguration_both
|
||||
);
|
||||
messager.printMessage( method.getExecutable(), reversePrism.mirror, Message.INHERITCONFIGURATION_BOTH );
|
||||
}
|
||||
|
||||
}
|
||||
@ -524,10 +514,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
);
|
||||
|
||||
if ( candidatePrism != null ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritinverseconfiguration_referencehasinverse,
|
||||
Message.INHERITINVERSECONFIGURATION_REFERENCE_HAS_INVERSE,
|
||||
candidate.getName()
|
||||
);
|
||||
}
|
||||
@ -536,10 +525,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
candidate.getExecutable()
|
||||
);
|
||||
if ( candidateTemplatePrism != null ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritinverseconfiguration_referencehasforward,
|
||||
Message.INHERITINVERSECONFIGURATION_REFERENCE_HAS_FORWARD,
|
||||
candidate.getName()
|
||||
);
|
||||
}
|
||||
@ -555,19 +543,17 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
|
||||
String name = reversePrism.name();
|
||||
if ( name.isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritinverseconfiguration_duplicates,
|
||||
Message.INHERITINVERSECONFIGURATION_DUPLICATES,
|
||||
Strings.join( candidateNames, "(), " )
|
||||
|
||||
);
|
||||
}
|
||||
else {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritinverseconfiguration_invalidname,
|
||||
Message.INHERITINVERSECONFIGURATION_INVALID_NAME,
|
||||
Strings.join( candidateNames, "(), " ),
|
||||
name
|
||||
|
||||
@ -578,10 +564,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
private void reportErrorWhenSeveralNamesMatch(List<SourceMethod> candidates, SourceMethod method,
|
||||
InheritInverseConfigurationPrism reversePrism) {
|
||||
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritinverseconfiguration_duplicatematches,
|
||||
Message.INHERITINVERSECONFIGURATION_DUPLICATE_MATCHES,
|
||||
reversePrism.name(),
|
||||
Strings.join( candidates, "(), " )
|
||||
|
||||
@ -591,10 +576,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
private void reportErrorWhenNonMatchingName(SourceMethod onlyCandidate, SourceMethod method,
|
||||
InheritInverseConfigurationPrism reversePrism) {
|
||||
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
reversePrism.mirror,
|
||||
Message.inheritinverseconfiguration_nonamematch,
|
||||
Message.INHERITINVERSECONFIGURATION_NO_NAME_MATCH,
|
||||
reversePrism.name(),
|
||||
onlyCandidate.getName()
|
||||
);
|
||||
@ -609,10 +593,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
);
|
||||
|
||||
if ( candidatePrism != null ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
prism.mirror,
|
||||
Message.inheritconfiguration_referencehasforward,
|
||||
Message.INHERITCONFIGURATION_REFERENCE_HAS_FORWARD,
|
||||
candidate.getName()
|
||||
);
|
||||
}
|
||||
@ -622,10 +605,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
);
|
||||
|
||||
if ( candidateInversePrism != null ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
prism.mirror,
|
||||
Message.inheritconfiguration_referencehasinverse,
|
||||
Message.INHERITCONFIGURATION_REFERENCE_HAS_INVERSE,
|
||||
candidate.getName()
|
||||
);
|
||||
}
|
||||
@ -641,18 +623,16 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
|
||||
String name = prism.name();
|
||||
if ( name.isEmpty() ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
prism.mirror,
|
||||
Message.inheritconfiguration_duplicates,
|
||||
Message.INHERITCONFIGURATION_DUPLICATES,
|
||||
Strings.join( candidateNames, "(), " )
|
||||
);
|
||||
}
|
||||
else {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
prism.mirror,
|
||||
Message.inheritconfiguration_invalidname,
|
||||
Message.INHERITCONFIGURATION_INVALIDNAME,
|
||||
Strings.join( candidateNames, "(), " ),
|
||||
name
|
||||
);
|
||||
@ -662,10 +642,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
private void reportErrorWhenSeveralNamesMatch(List<SourceMethod> candidates, SourceMethod method,
|
||||
InheritConfigurationPrism prism) {
|
||||
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
prism.mirror,
|
||||
Message.inheritconfiguration_duplicatematches,
|
||||
Message.INHERITCONFIGURATION_DUPLICATE_MATCHES,
|
||||
prism.name(),
|
||||
Strings.join( candidates, "(), " )
|
||||
);
|
||||
@ -674,10 +653,9 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
private void reportErrorWhenNonMatchingName(SourceMethod onlyCandidate, SourceMethod method,
|
||||
InheritConfigurationPrism prims) {
|
||||
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
method.getExecutable(),
|
||||
messager.printMessage( method.getExecutable(),
|
||||
prims.mirror,
|
||||
Message.inheritconfiguration_nonamematch,
|
||||
Message.INHERITCONFIGURATION_NO_NAME_MATCH,
|
||||
prims.name(),
|
||||
onlyCandidate.getName()
|
||||
);
|
||||
|
@ -35,7 +35,6 @@ import javax.lang.model.type.TypeKind;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.util.Types;
|
||||
import javax.tools.Diagnostic.Kind;
|
||||
|
||||
import org.mapstruct.ap.model.common.Parameter;
|
||||
import org.mapstruct.ap.model.common.Type;
|
||||
@ -272,60 +271,60 @@ public class MethodRetrievalProcessor implements ModelElementProcessor<Void, Lis
|
||||
Parameter targetParameter, Type resultType, Type returnType,
|
||||
boolean containsTargetTypeParameter) {
|
||||
if ( sourceParameters.isEmpty() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_noinputargs );
|
||||
messager.printMessage( method, Message.RETRIEVAL_NO_INPUT_ARGS );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( targetParameter != null && ( sourceParameters.size() + 1 != method.getParameters().size() ) ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_duplicatemappingtargets );
|
||||
messager.printMessage( method, Message.RETRIEVAL_DUPLICATE_MAPPING_TARGETS );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( resultType.getTypeMirror().getKind() == TypeKind.VOID ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_voidmappingmethod );
|
||||
messager.printMessage( method, Message.RETRIEVAL_VOID_MAPPING_METHOD );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( returnType.getTypeMirror().getKind() != TypeKind.VOID &&
|
||||
!resultType.isAssignableTo( returnType ) ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_nonassignableresulttype );
|
||||
messager.printMessage( method, Message.RETRIEVAL_NON_ASSIGNABLE_RESULTTYPE );
|
||||
return false;
|
||||
}
|
||||
|
||||
Type parameterType = sourceParameters.get( 0 ).getType();
|
||||
|
||||
if ( parameterType.isIterableType() && !resultType.isIterableType() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_iterabletononiterable );
|
||||
messager.printMessage( method, Message.RETRIEVAL_ITERABLE_TO_NON_ITERABLE );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( containsTargetTypeParameter ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_mappinghastargettypeparameter );
|
||||
messager.printMessage( method, Message.RETRIEVAL_MAPPING_HAS_TARGET_TYPE_PARAMETER );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !parameterType.isIterableType() && resultType.isIterableType() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_noniterabletoiterable );
|
||||
messager.printMessage( method, Message.RETRIEVAL_NON_ITERABLE_TO_ITERABLE );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( parameterType.isPrimitive() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_primitiveparameter );
|
||||
messager.printMessage( method, Message.RETRIEVAL_PRIMITIVE_PARAMETER );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( resultType.isPrimitive() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_primitivereturn );
|
||||
messager.printMessage( method, Message.RETRIEVAL_PRIMITIVE_RETURN );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( parameterType.isEnumType() && !resultType.isEnumType() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_enumtononenum );
|
||||
messager.printMessage( method, Message.RETRIEVAL_ENUM_TO_NON_ENUM );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !parameterType.isEnumType() && resultType.isEnumType() ) {
|
||||
messager.printMessage( Kind.ERROR, method, Message.retrieval_nonenumtoenum );
|
||||
messager.printMessage( method, Message.RETRIEVAL_NON_ENUM_TO_ENUM );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ import org.mapstruct.ap.util.FormattingMessager;
|
||||
import javax.lang.model.type.TypeMirror;
|
||||
import javax.lang.model.util.Elements;
|
||||
import javax.lang.model.util.Types;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
import org.mapstruct.ap.conversion.ConversionProvider;
|
||||
import org.mapstruct.ap.conversion.Conversions;
|
||||
@ -465,18 +464,16 @@ public class MappingResolverImpl implements MappingResolver {
|
||||
if ( candidates.size() > 1 ) {
|
||||
|
||||
if ( mappedElement != null ) {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
mappingMethod.getExecutable(),
|
||||
Message.general_ambigiousmappingmethod,
|
||||
messager.printMessage( mappingMethod.getExecutable(),
|
||||
Message.GENERAL_AMBIGIOUS_MAPPING_METHOD,
|
||||
mappedElement,
|
||||
returnType,
|
||||
Strings.join( candidates, ", " )
|
||||
);
|
||||
}
|
||||
else {
|
||||
messager.printMessage( Diagnostic.Kind.ERROR,
|
||||
mappingMethod.getExecutable(),
|
||||
Message.general_ambigiousfactorymethod,
|
||||
messager.printMessage( mappingMethod.getExecutable(),
|
||||
Message.GENERAL_AMBIGIOUSFACTORY_METHOD,
|
||||
returnType,
|
||||
Strings.join( candidates, ", " )
|
||||
);
|
||||
|
@ -21,37 +21,33 @@ package org.mapstruct.ap.util;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
import javax.lang.model.element.AnnotationValue;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
public interface FormattingMessager {
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param msg the message
|
||||
* @param args Arguments referenced by the format specifiers in the format string. If there are more arguments
|
||||
* than format specifiers, the extra arguments are ignored
|
||||
*/
|
||||
void printMessage( Diagnostic.Kind kind, Message msg, Object... args);
|
||||
void printMessage(Message msg, Object... args);
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind at the location of the
|
||||
* element.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param e the element to use as a position hint
|
||||
* @param msg the message
|
||||
* @param args Arguments referenced by the format specifiers in the format string. If there are more arguments
|
||||
* than format specifiers, the extra arguments are ignored
|
||||
*/
|
||||
void printMessage( Diagnostic.Kind kind, Element e, Message msg, Object... args);
|
||||
void printMessage(Element e, Message msg, Object... args);
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind at the location of the
|
||||
* annotation mirror of the annotated element.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param e the annotated element
|
||||
* @param a the annotation to use as a position hint
|
||||
* @param msg the message
|
||||
@ -59,14 +55,13 @@ public interface FormattingMessager {
|
||||
* than format specifiers, the extra arguments are ignored
|
||||
*
|
||||
*/
|
||||
void printMessage( Diagnostic.Kind kind, Element e, AnnotationMirror a, Message msg, Object... args);
|
||||
void printMessage(Element e, AnnotationMirror a, Message msg, Object... args);
|
||||
|
||||
/**
|
||||
* Prints a message of the specified kind at the location of the
|
||||
* annotation value inside the annotation mirror of the annotated
|
||||
* element.
|
||||
*
|
||||
* @param kind the kind of message
|
||||
* @param e the annotated element
|
||||
* @param a the annotation containing the annotation value
|
||||
* @param v the annotation value to use as a position hint
|
||||
@ -74,8 +69,7 @@ public interface FormattingMessager {
|
||||
* @param args Arguments referenced by the format specifiers in the format string. If there are more arguments
|
||||
* than format specifiers, the extra arguments are ignored
|
||||
*/
|
||||
void printMessage( Diagnostic.Kind kind,
|
||||
Element e,
|
||||
void printMessage(Element e,
|
||||
AnnotationMirror a,
|
||||
AnnotationValue v,
|
||||
Message msg,
|
||||
|
@ -18,83 +18,99 @@
|
||||
*/
|
||||
package org.mapstruct.ap.util;
|
||||
|
||||
import javax.tools.Diagnostic;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public enum Message {
|
||||
|
||||
|
||||
// CHECKSTYLE:OFF
|
||||
beanmapping_noelements( "'resultType' and 'qualifiedBy' are undefined in @BeanMapping, define at least one of them." ),
|
||||
beanmapping_notassignable( "%s not assignable to: %s." ),
|
||||
beanmapping_unknownpropertyinreturntype( "Unknown property \"%s\" in return type." ),
|
||||
beanmapping_severalpossiblesources( "Several possible source properties for target property \"%s\"." ),
|
||||
beanmapping_severalpossibletargetaccessors( "Found several matching getters for property \"%s\"." ),
|
||||
beanmapping_unmappedtargets( "Unmapped target %s." ),
|
||||
propertymapping_mappingnotfound( "Can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ),
|
||||
propertymapping_duplicatetargets( "Target property \"%s\" must not be mapped more than once." ),
|
||||
propertymapping_emptytarget( "Target must not be empty in @Mapping." ),
|
||||
propertymapping_sourceandconstantbothdefined( "Source and constant are both defined in @Mapping, either define a source or a constant." ),
|
||||
propertymapping_sourceandexpressionbothdefined( "Source and expression are both defined in @Mapping, either define a source or an expression." ),
|
||||
propertymapping_expressionandconstantbothdefined( "Expression and constant are both defined in @Mapping, either define an expression or a constant." ),
|
||||
propertymapping_invalidexpression( "Value must be given in the form \"java(<EXPRESSION>)\"." ),
|
||||
propertymapping_reversalproblem( "Parameter %s cannot be reversed." ),
|
||||
propertymapping_invalidparametername( "Method has no parameter named \"%s\"." ),
|
||||
propertymapping_nopropertyinparameter( "The type of parameter \"%s\" has no property named \"%s\"." ),
|
||||
propertymapping_invalidpropertyname( "No property named \"%s\" exists in source parameter(s)." ),
|
||||
constantmapping_mappingnotfound( "Can't map \"%s %s\" to \"%s %s\"." ),
|
||||
mapmapping_key_mappingnotfound( "Can't create implementation of method %s. Found no method nor built-in conversion for mapping source key type to target key type." ),
|
||||
mapmapping_value_mappingnotfound( "Can't create implementation of method %s. Found no method nor built-in conversion for mapping source value type to target value type." ),
|
||||
mapmapping_noelements( "'keyDateFormat', 'keyQualifiedBy', 'keyTargetType', 'valueDateFormat', 'valueQualfiedBy' and 'valueTargetType' are all undefined in @MapMapping, define at least one of them." ),
|
||||
iterablemapping_mappingnotfound( "Can't create implementation of method %s. Found no method nor built-in conversion for mapping source element type into target element type." ),
|
||||
iterablemapping_noelements( "'dateformat', 'qualifiedBy' and 'elementTargetType' are undefined in @IterableMapping, define at least one of them." ),
|
||||
enummapping_multipletargets( "One enum constant must not be mapped to more than one target constant, but constant %s is mapped to %s." ),
|
||||
enummapping_undefinedsource( "A source constant must be specified for mappings of an enum mapping method." ),
|
||||
enummapping_nonexistingconstant( "Constant %s doesn't exist in enum type %s." ),
|
||||
enummapping_undefinedtarget( "A target constant must be specified for mappings of an enum mapping method." ),
|
||||
enummapping_unmappedtargets( "The following constants from the source enum have no corresponding constant in the target enum and must be be mapped via @Mapping: %s." ),
|
||||
decorator_nosubtype( "Specified decorator type is no subtype of the annotated mapper type." ),
|
||||
decorator_constructor( "Specified decorator type has no default constructor nor a constructor with a single parameter accepting the decorated mapper type." ),
|
||||
general_noimplementation( "No implementation type is registered for return type %s." ),
|
||||
general_ambigiousmappingmethod( "Ambiguous mapping methods found for mapping %s to %s: %s." ),
|
||||
general_ambigiousfactorymethod( "Ambiguous mapping methods found for factorizing %s: %s." ),
|
||||
general_unsupporteddateformatcheck( "No dateFormat check is supported for types %s, %s" ),
|
||||
general_validdate( "given date format \"%s\" is valid." ),
|
||||
general_invaliddate( "given date format \"%s\" is invalid. Message: \"%s\"." ),
|
||||
retrieval_noinputargs( "Can't generate mapping method with no input arguments." ),
|
||||
retrieval_duplicatemappingtargets( "Can't generate mapping method with more than one @MappingTarget parameter." ),
|
||||
retrieval_voidmappingmethod( "Can't generate mapping method with return type void." ),
|
||||
retrieval_nonassignableresulttype( "The result type is not assignable to the the return type." ),
|
||||
retrieval_iterabletononiterable( "Can't generate mapping method from iterable type to non-iterable type." ),
|
||||
retrieval_mappinghastargettypeparameter( "Can't generate mapping method that has a parameter annotated with @TargetType." ),
|
||||
retrieval_noniterabletoiterable( "Can't generate mapping method from non-iterable type to iterable type." ),
|
||||
retrieval_primitiveparameter( "Can't generate mapping method with primitive parameter type." ),
|
||||
retrieval_primitivereturn( "Can't generate mapping method with primitive return type." ),
|
||||
retrieval_enumtononenum( "Can't generate mapping method from enum type to non-enum type." ),
|
||||
retrieval_nonenumtoenum( "Can't generate mapping method from non-enum type to enum type." ),
|
||||
inheritconfiguration_both( "Method cannot be annotated with both a @InheritConfiguration and @InheritInverseConfiguration." ),
|
||||
inheritinverseconfiguration_referencehasinverse( "Resolved inverse mapping method %s() should not carry the @InheritInverseConfiguration annotation itself." ),
|
||||
inheritinverseconfiguration_referencehasforward( "Resolved inverse mapping method %s() should not carry the @InheritConfiguration annotation." ),
|
||||
inheritinverseconfiguration_duplicates( "Several matching inverse methods exist: %s(). Specify a name explicitly." ),
|
||||
inheritinverseconfiguration_invalidname( "None of the candidates %s() matches given name: \"%s\"." ),
|
||||
inheritinverseconfiguration_duplicatematches( "Given name \"%s\" matches several candidate methods: %s()." ),
|
||||
inheritinverseconfiguration_nonamematch( "Given name \"%s\" does not match the only candidate. Did you mean: \"%s\"." ),
|
||||
inheritconfiguration_referencehasforward( "Resolved mapping method %s() should not carry the @InheritConfiguration annotation itself." ),
|
||||
inheritconfiguration_referencehasinverse( "Resolved mapping method %s() should not carry the @InheritInverseConfiguration annotation." ),
|
||||
inheritconfiguration_duplicates( "Several matching methods exist: %s(). Specify a name explicitly." ),
|
||||
inheritconfiguration_invalidname( "None of the candidates %s() matches given name: \"%s\"." ),
|
||||
inheritconfiguration_duplicatematches( "Given name \"%s\" matches several candidate methods: %s()." ),
|
||||
inheritconfiguration_nonamematch( "Given name \"%s\" does not match the only candidate. Did you mean: \"%s\"." );
|
||||
// CHECKSTYLE:OFF
|
||||
BEANMAPPING_NO_ELEMENTS( "'resultType' and 'qualifiedBy' are undefined in @BeanMapping, define at least one of them." ),
|
||||
BEANMAPPING_NOT_ASSIGNABLE( "%s not assignable to: %s." ),
|
||||
BEANMAPPING_UNKNOWN_PROPERTY_IN_RETURNTYPE( "Unknown property \"%s\" in return type." ),
|
||||
BEANMAPPING_SEVERAL_POSSIBLE_SOURCES( "Several possible source properties for target property \"%s\"." ),
|
||||
BEANMAPPING_SEVERAL_POSSIBLE_TARGET_ACCESSORS( "Found several matching getters for property \"%s\"." ),
|
||||
BEANMAPPING_UNMAPPED_TARGETS_WARNING( "Unmapped target %s.", Diagnostic.Kind.WARNING ),
|
||||
BEANMAPPING_UNMAPPED_TARGETS_ERROR( "Unmapped target %s." ),
|
||||
PROPERTYMAPPING_MAPPING_NOT_FOUND( "Can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ),
|
||||
PROPERTYMAPPING_DUPLICATE_TARGETS( "Target property \"%s\" must not be mapped more than once." ),
|
||||
PROPERTYMAPPING_EMPTY_TARGET( "Target must not be empty in @Mapping." ),
|
||||
PROPERTYMAPPING_SOURCE_AND_CONSTANT_BOTH_DEFINED( "Source and constant are both defined in @Mapping, either define a source or a constant." ),
|
||||
PROPERTYMAPPING_SOURCE_AND_EXPRESSION_BOTH_DEFINED( "Source and expression are both defined in @Mapping, either define a source or an expression." ),
|
||||
PROPERTYMAPPING_EXPRESSION_AND_CONSTANT_BOTH_DEFINED( "Expression and constant are both defined in @Mapping, either define an expression or a constant." ),
|
||||
PROPERTYMAPPING_INVALID_EXPRESSION( "Value must be given in the form \"java(<EXPRESSION>)\"." ),
|
||||
PROPERTYMAPPING_REVERSAL_PROBLEM( "Parameter %s cannot be reversed." ),
|
||||
PROPERTYMAPPING_INVALID_PARAMETER_NAME( "Method has no parameter named \"%s\"." ),
|
||||
PROPERTYMAPPING_NO_PROPERTY_IN_PARAMETER( "The type of parameter \"%s\" has no property named \"%s\"." ),
|
||||
PROPERTYMAPPING_INVALID_PROPERTY_NAME( "No property named \"%s\" exists in source parameter(s)." ),
|
||||
CONSTANTMAPPING_MAPPING_NOT_FOUND( "Can't map \"%s %s\" to \"%s %s\"." ),
|
||||
MAPMAPPING_KEY_MAPPING_NOT_FOUND( "Can't create implementation of method %s. Found no method nor built-in conversion for mapping source key type to target key type." ),
|
||||
MAPMAPPING_VALUE_MAPPING_NOT_FOUND( "Can't create implementation of method %s. Found no method nor built-in conversion for mapping source value type to target value type." ),
|
||||
MAPMAPPING_NO_ELEMENTS( "'keyDateFormat', 'keyQualifiedBy', 'keyTargetType', 'valueDateFormat', 'valueQualfiedBy' and 'valueTargetType' are all undefined in @MapMapping, define at least one of them." ),
|
||||
ITERABLEMAPPING_MAPPING_NOT_FOUND( "Can't create implementation of method %s. Found no method nor built-in conversion for mapping source element type into target element type." ),
|
||||
ITERABLEMAPPING_NO_ELEMENTS( "'dateformat', 'qualifiedBy' and 'elementTargetType' are undefined in @IterableMapping, define at least one of them." ),
|
||||
ENUMMAPPING_MULTIPLE_TARGETS( "One enum constant must not be mapped to more than one target constant, but constant %s is mapped to %s." ),
|
||||
ENUMMAPPING_UNDEFINED_SOURCE( "A source constant must be specified for mappings of an enum mapping method." ),
|
||||
ENUMMAPPING_NON_EXISTING_CONSTANT( "Constant %s doesn't exist in enum type %s." ),
|
||||
ENUMMAPPING_UNDEFINED_TARGET( "A target constant must be specified for mappings of an enum mapping method." ),
|
||||
ENUMMAPPING_UNMAPPED_TARGETS( "The following constants from the source enum have no corresponding constant in the target enum and must be be mapped via @Mapping: %s." ),
|
||||
DECORATOR_NO_SUBTYPE( "Specified decorator type is no subtype of the annotated mapper type." ),
|
||||
DECORATOR_CONSTRUCTOR( "Specified decorator type has no default constructor nor a constructor with a single parameter accepting the decorated mapper type." ),
|
||||
GENERAL_NO_IMPLEMENTATION( "No implementation type is registered for return type %s." ),
|
||||
GENERAL_AMBIGIOUS_MAPPING_METHOD( "Ambiguous mapping methods found for mapping %s to %s: %s." ),
|
||||
GENERAL_AMBIGIOUSFACTORY_METHOD( "Ambiguous mapping methods found for factorizing %s: %s." ),
|
||||
GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK( "No dateFormat check is supported for types %s, %s" ),
|
||||
GENERAL_VALID_DATE( "given date format \"%s\" is valid." ),
|
||||
GENERAL_INVALID_DATE( "given date format \"%s\" is invalid. Message: \"%s\"." ),
|
||||
RETRIEVAL_NO_INPUT_ARGS( "Can't generate mapping method with no input arguments." ),
|
||||
RETRIEVAL_DUPLICATE_MAPPING_TARGETS( "Can't generate mapping method with more than one @MappingTarget parameter." ),
|
||||
RETRIEVAL_VOID_MAPPING_METHOD( "Can't generate mapping method with return type void." ),
|
||||
RETRIEVAL_NON_ASSIGNABLE_RESULTTYPE( "The result type is not assignable to the the return type." ),
|
||||
RETRIEVAL_ITERABLE_TO_NON_ITERABLE( "Can't generate mapping method from iterable type to non-iterable type." ),
|
||||
RETRIEVAL_MAPPING_HAS_TARGET_TYPE_PARAMETER( "Can't generate mapping method that has a parameter annotated with @TargetType." ),
|
||||
RETRIEVAL_NON_ITERABLE_TO_ITERABLE( "Can't generate mapping method from non-iterable type to iterable type." ),
|
||||
RETRIEVAL_PRIMITIVE_PARAMETER( "Can't generate mapping method with primitive parameter type." ),
|
||||
RETRIEVAL_PRIMITIVE_RETURN( "Can't generate mapping method with primitive return type." ),
|
||||
RETRIEVAL_ENUM_TO_NON_ENUM( "Can't generate mapping method from enum type to non-enum type." ),
|
||||
RETRIEVAL_NON_ENUM_TO_ENUM( "Can't generate mapping method from non-enum type to enum type." ),
|
||||
INHERITCONFIGURATION_BOTH( "Method cannot be annotated with both a @InheritConfiguration and @InheritInverseConfiguration." ),
|
||||
INHERITINVERSECONFIGURATION_REFERENCE_HAS_INVERSE( "Resolved inverse mapping method %s() should not carry the @InheritInverseConfiguration annotation itself." ),
|
||||
INHERITINVERSECONFIGURATION_REFERENCE_HAS_FORWARD( "Resolved inverse mapping method %s() should not carry the @InheritConfiguration annotation." ),
|
||||
INHERITINVERSECONFIGURATION_DUPLICATES( "Several matching inverse methods exist: %s(). Specify a name explicitly." ),
|
||||
INHERITINVERSECONFIGURATION_INVALID_NAME( "None of the candidates %s() matches given name: \"%s\"." ),
|
||||
INHERITINVERSECONFIGURATION_DUPLICATE_MATCHES( "Given name \"%s\" matches several candidate methods: %s()." ),
|
||||
INHERITINVERSECONFIGURATION_NO_NAME_MATCH( "Given name \"%s\" does not match the only candidate. Did you mean: \"%s\"." ),
|
||||
INHERITCONFIGURATION_REFERENCE_HAS_FORWARD( "Resolved mapping method %s() should not carry the @InheritConfiguration annotation itself." ),
|
||||
INHERITCONFIGURATION_REFERENCE_HAS_INVERSE( "Resolved mapping method %s() should not carry the @InheritInverseConfiguration annotation." ),
|
||||
INHERITCONFIGURATION_DUPLICATES( "Several matching methods exist: %s(). Specify a name explicitly." ),
|
||||
INHERITCONFIGURATION_INVALIDNAME( "None of the candidates %s() matches given name: \"%s\"." ),
|
||||
INHERITCONFIGURATION_DUPLICATE_MATCHES( "Given name \"%s\" matches several candidate methods: %s()." ),
|
||||
INHERITCONFIGURATION_NO_NAME_MATCH( "Given name \"%s\" does not match the only candidate. Did you mean: \"%s\"." );
|
||||
// CHECKSTYLE:ON
|
||||
|
||||
private final String description;
|
||||
private final Diagnostic.Kind kind;
|
||||
|
||||
private Message(String description) {
|
||||
this.description = description;
|
||||
this.kind = Diagnostic.Kind.ERROR;
|
||||
}
|
||||
|
||||
private Message(String description, Diagnostic.Kind kind) {
|
||||
this.description = description;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public Diagnostic.Kind getDiagnosticKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -125,21 +125,20 @@ public class DefaultConversionContextTest {
|
||||
private Diagnostic.Kind lastKindPrinted;
|
||||
|
||||
@Override
|
||||
public void printMessage( Diagnostic.Kind kind, Message msg, Object... arg) {
|
||||
lastKindPrinted = kind;
|
||||
public void printMessage(Message msg, Object... arg) {
|
||||
lastKindPrinted = msg.getDiagnosticKind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Diagnostic.Kind kind, Element e, Message msg, Object... arg) {
|
||||
public void printMessage(Element e, Message msg, Object... arg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Diagnostic.Kind kind, Element e, AnnotationMirror a, Message msg, Object... arg) {
|
||||
public void printMessage(Element e, AnnotationMirror a, Message msg, Object... arg) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printMessage( Diagnostic.Kind kind, Element e, AnnotationMirror a, AnnotationValue v,
|
||||
Message msg, Object... arg) {
|
||||
public void printMessage(Element e, AnnotationMirror a, AnnotationValue v, Message msg, Object... arg) {
|
||||
}
|
||||
|
||||
public Diagnostic.Kind getLastKindPrinted() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user