mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
This commit is contained in:
parent
fe22c9b1ce
commit
66055f024b
@ -829,7 +829,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod {
|
|||||||
ForgedMethodHistory history = forgedMethod.getHistory();
|
ForgedMethodHistory history = forgedMethod.getHistory();
|
||||||
ctx.getMessager().printMessage(
|
ctx.getMessager().printMessage(
|
||||||
this.method.getExecutable(),
|
this.method.getExecutable(),
|
||||||
Message.PROPERTYMAPPING_MAPPING_NOT_FOUND,
|
Message.PROPERTYMAPPING_FORGED_MAPPING_WITH_HISTORY_NOT_FOUND,
|
||||||
history.createSourcePropertyErrorMessage(),
|
history.createSourcePropertyErrorMessage(),
|
||||||
history.getTargetType(),
|
history.getTargetType(),
|
||||||
history.createTargetPropertyName(),
|
history.createTargetPropertyName(),
|
||||||
|
@ -184,7 +184,6 @@ public class MapMappingMethod extends NormalTypeMappingMethod {
|
|||||||
.getFactoryMethod( method, null, ctx );
|
.getFactoryMethod( method, null, ctx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
keyAssignment = new LocalVarWrapper( keyAssignment, method.getThrownTypes(), keyTargetType, false );
|
keyAssignment = new LocalVarWrapper( keyAssignment, method.getThrownTypes(), keyTargetType, false );
|
||||||
valueAssignment = new LocalVarWrapper( valueAssignment, method.getThrownTypes(), valueTargetType, false );
|
valueAssignment = new LocalVarWrapper( valueAssignment, method.getThrownTypes(), valueTargetType, false );
|
||||||
|
|
||||||
|
@ -32,7 +32,8 @@ public enum Message {
|
|||||||
BEANMAPPING_UNKNOWN_PROPERTY_IN_DEPENDS_ON( "\"%s\" is no property of the method return type." ),
|
BEANMAPPING_UNKNOWN_PROPERTY_IN_DEPENDS_ON( "\"%s\" is no property of the method return type." ),
|
||||||
|
|
||||||
PROPERTYMAPPING_MAPPING_NOT_FOUND( "Can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ),
|
PROPERTYMAPPING_MAPPING_NOT_FOUND( "Can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ),
|
||||||
PROPERTYMAPPING_FORGED_MAPPING_NOT_FOUND( "Can't map %s to %s. Consider to implement a mapping method: \"%s map(%s value)\"." ),
|
PROPERTYMAPPING_FORGED_MAPPING_WITH_HISTORY_NOT_FOUND( "No target bean properties found: can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ),
|
||||||
|
PROPERTYMAPPING_FORGED_MAPPING_NOT_FOUND( "No target bean properties found: can't map %s to %s. Consider to implement a mapping method: \"%s map(%s value)\"." ),
|
||||||
PROPERTYMAPPING_DUPLICATE_TARGETS( "Target property \"%s\" must not be mapped more than once." ),
|
PROPERTYMAPPING_DUPLICATE_TARGETS( "Target property \"%s\" must not be mapped more than once." ),
|
||||||
PROPERTYMAPPING_EMPTY_TARGET( "Target must not be empty in @Mapping." ),
|
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_CONSTANT_BOTH_DEFINED( "Source and constant are both defined in @Mapping, either define a source or a constant." ),
|
||||||
|
@ -104,9 +104,9 @@ public class ErroneousCollectionMappingTest {
|
|||||||
@Diagnostic(type = ErroneousCollectionNoElementMappingFound.class,
|
@Diagnostic(type = ErroneousCollectionNoElementMappingFound.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 25,
|
line = 25,
|
||||||
messageRegExp = "Can't map Collection element \".*WithProperties withProperties\" to \".*NoProperties" +
|
messageRegExp = "No target bean properties found: can't map Collection element \".*WithProperties "
|
||||||
" noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" +
|
+ "withProperties\" to \".*NoProperties noProperties\". Consider to declare/implement "
|
||||||
".*WithProperties value\\)")
|
+ "a mapping method: \".*NoProperties map\\(.*WithProperties value\\)")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoElementMappingFound() {
|
public void shouldFailOnNoElementMappingFound() {
|
||||||
@ -138,9 +138,10 @@ public class ErroneousCollectionMappingTest {
|
|||||||
@Diagnostic(type = ErroneousCollectionNoKeyMappingFound.class,
|
@Diagnostic(type = ErroneousCollectionNoKeyMappingFound.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 25,
|
line = 25,
|
||||||
messageRegExp = "Can't map Map key \".*WithProperties withProperties\" to \".*NoProperties " +
|
messageRegExp = "No target bean properties found: can't map Map key \".*WithProperties "
|
||||||
"noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" +
|
+ "withProperties\" to "
|
||||||
".*WithProperties value\\)")
|
+ "\".*NoProperties noProperties\". Consider to declare/implement a mapping method: "
|
||||||
|
+ "\".*NoProperties map\\(.*WithProperties value\\)" )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoKeyMappingFound() {
|
public void shouldFailOnNoKeyMappingFound() {
|
||||||
@ -171,9 +172,10 @@ public class ErroneousCollectionMappingTest {
|
|||||||
@Diagnostic(type = ErroneousCollectionNoValueMappingFound.class,
|
@Diagnostic(type = ErroneousCollectionNoValueMappingFound.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 25,
|
line = 25,
|
||||||
messageRegExp = "Can't map Map value \".*WithProperties withProperties\" to \".*NoProperties " +
|
messageRegExp = "No target bean properties found: can't map Map value \".*WithProperties "
|
||||||
"noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" +
|
+ "withProperties\" to "
|
||||||
".*WithProperties value\\)")
|
+ "\".*NoProperties noProperties\". Consider to declare/implement a mapping method: "
|
||||||
|
+ "\".*NoProperties map\\(.*WithProperties value\\)" )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoValueMappingFound() {
|
public void shouldFailOnNoValueMappingFound() {
|
||||||
|
@ -87,8 +87,8 @@ public class CollectionMappingTest {
|
|||||||
@Diagnostic(type = ErroneousCollectionNonMappableSetMapper.class,
|
@Diagnostic(type = ErroneousCollectionNonMappableSetMapper.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 17,
|
line = 17,
|
||||||
messageRegExp = "Can't map Collection element \".* nonMappableSet\" to \".* nonMappableSet\". "
|
messageRegExp = "No target bean properties found: can't map Collection element \".* nonMappableSet\" "
|
||||||
+ "Consider to declare/implement a mapping method: .*."),
|
+ "to \".* nonMappableSet\". Consider to declare/implement a mapping method: .*." ),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldGenerateNonMappleMethodForSetMapping() {
|
public void shouldGenerateNonMappleMethodForSetMapping() {
|
||||||
@ -107,13 +107,15 @@ public class CollectionMappingTest {
|
|||||||
@Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class,
|
@Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 17,
|
line = 17,
|
||||||
messageRegExp = "Can't map Map key \".* nonMappableMap\\{:key\\}\" to \".* nonMappableMap\\{:key\\}\". "
|
messageRegExp = "No target bean properties found: can't map Map key \".* nonMappableMap\\{:key\\}\" "
|
||||||
+ "Consider to declare/implement a mapping method: .*."),
|
+ "to \".* "
|
||||||
|
+ "nonMappableMap\\{:key\\}\". Consider to declare/implement a mapping method: .*." ),
|
||||||
@Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class,
|
@Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 17,
|
line = 17,
|
||||||
messageRegExp = "Can't map Map value \".* nonMappableMap\\{:value\\}\" to \".* " +
|
messageRegExp = "No target bean properties found: can't map Map value \".* "
|
||||||
"nonMappableMap\\{:value\\}\". Consider to declare/implement a mapping method: .*."),
|
+ "nonMappableMap\\{:value\\}\" to \".* nonMappableMap\\{:value\\}\". "
|
||||||
|
+ "Consider to declare/implement a mapping method: .*." ),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldGenerateNonMappleMethodForMapMapping() {
|
public void shouldGenerateNonMappleMethodForMapMapping() {
|
||||||
|
@ -104,9 +104,10 @@ public class ErroneousStreamMappingTest {
|
|||||||
@Diagnostic(type = ErroneousStreamToStreamNoElementMappingFound.class,
|
@Diagnostic(type = ErroneousStreamToStreamNoElementMappingFound.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 24,
|
line = 24,
|
||||||
messageRegExp = "Can't map Stream element \".*WithProperties withProperties\" to \".*NoProperties " +
|
messageRegExp = "No target bean properties found: can't map Stream element \".*WithProperties "
|
||||||
"noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" +
|
+ "withProperties\" to \".*NoProperties noProperties\". "
|
||||||
".*WithProperties value\\)")
|
+ "Consider to declare/implement a mapping method: \".*NoProperties "
|
||||||
|
+ "map\\(.*WithProperties value\\)" )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoElementMappingFoundForStreamToStream() {
|
public void shouldFailOnNoElementMappingFoundForStreamToStream() {
|
||||||
@ -136,10 +137,11 @@ public class ErroneousStreamMappingTest {
|
|||||||
@Diagnostic(type = ErroneousListToStreamNoElementMappingFound.class,
|
@Diagnostic(type = ErroneousListToStreamNoElementMappingFound.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 25,
|
line = 25,
|
||||||
messageRegExp =
|
messageRegExp = "No target bean properties found: can't map Stream element \".*WithProperties "
|
||||||
"Can't map Stream element \".*WithProperties withProperties\" to \".*NoProperties noProperties\"." +
|
+ "withProperties\" to \".*NoProperties noProperties\"."
|
||||||
" Consider to declare/implement a mapping method: \".*NoProperties map\\(.*WithProperties " +
|
+ " Consider to declare/implement a mapping method: \".*NoProperties map\\("
|
||||||
"value\\)")
|
+ ".*WithProperties "
|
||||||
|
+ "value\\)" )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoElementMappingFoundForListToStream() {
|
public void shouldFailOnNoElementMappingFoundForListToStream() {
|
||||||
@ -154,8 +156,9 @@ public class ErroneousStreamMappingTest {
|
|||||||
@Diagnostic(type = ErroneousListToStreamNoElementMappingFoundDisabledAuto.class,
|
@Diagnostic(type = ErroneousListToStreamNoElementMappingFoundDisabledAuto.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 20,
|
line = 20,
|
||||||
messageRegExp = "Can't map stream element \".*AttributedString\" to \".*String \". Consider to " +
|
messageRegExp = "Can't map stream element \".*AttributedString\" to "
|
||||||
"declare/implement a mapping method: \".*String map\\(.*AttributedString value\\)")
|
+ "\".*String \". Consider to declare/implement a mapping method: \".*String "
|
||||||
|
+ "map\\(.*AttributedString value\\)" )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoElementMappingFoundForListToStreamWithDisabledAuto() {
|
public void shouldFailOnNoElementMappingFoundForListToStreamWithDisabledAuto() {
|
||||||
@ -169,9 +172,10 @@ public class ErroneousStreamMappingTest {
|
|||||||
@Diagnostic(type = ErroneousStreamToListNoElementMappingFound.class,
|
@Diagnostic(type = ErroneousStreamToListNoElementMappingFound.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 25,
|
line = 25,
|
||||||
messageRegExp =
|
messageRegExp = "No target bean properties found: can't map Stream element \".*WithProperties "
|
||||||
"Can't map Stream element \".*WithProperties withProperties\" to .*NoProperties noProperties\"." +
|
+ "withProperties\" to .*NoProperties noProperties\"."
|
||||||
" Consider to declare/implement a mapping method: \".*NoProperties map(.*WithProperties value)")
|
+ " Consider to declare/implement a mapping method: \".*NoProperties map("
|
||||||
|
+ ".*WithProperties value)" )
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public void shouldFailOnNoElementMappingFoundForStreamToList() {
|
public void shouldFailOnNoElementMappingFoundForStreamToList() {
|
||||||
|
@ -70,9 +70,8 @@ public class ForgedStreamMappingTest {
|
|||||||
@Diagnostic(type = ErroneousStreamNonMappableStreamMapper.class,
|
@Diagnostic(type = ErroneousStreamNonMappableStreamMapper.class,
|
||||||
kind = Kind.ERROR,
|
kind = Kind.ERROR,
|
||||||
line = 17,
|
line = 17,
|
||||||
messageRegExp = "Can't map Stream element \".* nonMappableStream\" to \".* nonMappableStream\". "
|
messageRegExp = "No target bean properties found: can't map Stream element \".* nonMappableStream\" "
|
||||||
+ "Consider to declare/implement a mapping method: .*."),
|
+ "to \".* nonMappableStream\". Consider to declare/implement a mapping method: .*." ) }
|
||||||
}
|
|
||||||
)
|
)
|
||||||
public void shouldGenerateNonMappableMethodForSetMapping() {
|
public void shouldGenerateNonMappableMethodForSetMapping() {
|
||||||
}
|
}
|
||||||
|
@ -85,9 +85,9 @@ public class ConversionTest {
|
|||||||
diagnostics = {
|
diagnostics = {
|
||||||
@Diagnostic(type = ErroneousSourceTargetMapper1.class,
|
@Diagnostic(type = ErroneousSourceTargetMapper1.class,
|
||||||
kind = javax.tools.Diagnostic.Kind.ERROR, line = 16,
|
kind = javax.tools.Diagnostic.Kind.ERROR, line = 16,
|
||||||
messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.UpperBoundWrapper"
|
messageRegExp = "No target bean properties found: can't map property \"org.mapstruct.ap.test.selection."
|
||||||
+ "<org.mapstruct.ap.test.selection.generics.TypeA> fooUpperBoundFailure\" to "
|
+ "generics.UpperBoundWrapper<org.mapstruct.ap.test.selection.generics.TypeA> "
|
||||||
+ "\"org.mapstruct.ap.test.selection.generics.TypeA fooUpperBoundFailure\"")
|
+ "fooUpperBoundFailure\" to \"org.mapstruct.ap.test.selection.generics.TypeA fooUpperBoundFailure\"")
|
||||||
})
|
})
|
||||||
public void shouldFailOnUpperBound() {
|
public void shouldFailOnUpperBound() {
|
||||||
}
|
}
|
||||||
@ -99,7 +99,8 @@ public class ConversionTest {
|
|||||||
@Diagnostic(type = ErroneousSourceTargetMapper2.class,
|
@Diagnostic(type = ErroneousSourceTargetMapper2.class,
|
||||||
kind = javax.tools.Diagnostic.Kind.ERROR,
|
kind = javax.tools.Diagnostic.Kind.ERROR,
|
||||||
line = 16,
|
line = 16,
|
||||||
messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardExtendsWrapper"
|
messageRegExp = "No target bean properties found: can't map property "
|
||||||
|
+ "\"org.mapstruct.ap.test.selection.generics.WildCardExtendsWrapper"
|
||||||
+ "<org.mapstruct.ap.test.selection.generics.TypeA> fooWildCardExtendsTypeAFailure\" to"
|
+ "<org.mapstruct.ap.test.selection.generics.TypeA> fooWildCardExtendsTypeAFailure\" to"
|
||||||
+ " \"org.mapstruct.ap.test.selection.generics.TypeA fooWildCardExtendsTypeAFailure\"")
|
+ " \"org.mapstruct.ap.test.selection.generics.TypeA fooWildCardExtendsTypeAFailure\"")
|
||||||
})
|
})
|
||||||
@ -113,7 +114,8 @@ public class ConversionTest {
|
|||||||
@Diagnostic(type = ErroneousSourceTargetMapper3.class,
|
@Diagnostic(type = ErroneousSourceTargetMapper3.class,
|
||||||
kind = javax.tools.Diagnostic.Kind.ERROR,
|
kind = javax.tools.Diagnostic.Kind.ERROR,
|
||||||
line = 16,
|
line = 16,
|
||||||
messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics."
|
messageRegExp = "No target bean properties found: can't map property "
|
||||||
|
+ "\"org.mapstruct.ap.test.selection.generics."
|
||||||
+ "WildCardExtendsMBWrapper<org.mapstruct.ap.test.selection.generics.TypeB> "
|
+ "WildCardExtendsMBWrapper<org.mapstruct.ap.test.selection.generics.TypeB> "
|
||||||
+ "fooWildCardExtendsMBTypeBFailure\" to \"org.mapstruct.ap.test.selection.generics.TypeB "
|
+ "fooWildCardExtendsMBTypeBFailure\" to \"org.mapstruct.ap.test.selection.generics.TypeB "
|
||||||
+ "fooWildCardExtendsMBTypeBFailure\"")
|
+ "fooWildCardExtendsMBTypeBFailure\"")
|
||||||
@ -128,7 +130,8 @@ public class ConversionTest {
|
|||||||
@Diagnostic(type = ErroneousSourceTargetMapper4.class,
|
@Diagnostic(type = ErroneousSourceTargetMapper4.class,
|
||||||
kind = javax.tools.Diagnostic.Kind.ERROR,
|
kind = javax.tools.Diagnostic.Kind.ERROR,
|
||||||
line = 16,
|
line = 16,
|
||||||
messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper"
|
messageRegExp = "No target bean properties found: can't map property "
|
||||||
|
+ "\"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper"
|
||||||
+ "<org.mapstruct.ap.test.selection.generics.TypeA> fooWildCardSuperTypeAFailure\" to"
|
+ "<org.mapstruct.ap.test.selection.generics.TypeA> fooWildCardSuperTypeAFailure\" to"
|
||||||
+ " \"org.mapstruct.ap.test.selection.generics.TypeA fooWildCardSuperTypeAFailure\"")
|
+ " \"org.mapstruct.ap.test.selection.generics.TypeA fooWildCardSuperTypeAFailure\"")
|
||||||
})
|
})
|
||||||
@ -142,7 +145,8 @@ public class ConversionTest {
|
|||||||
@Diagnostic(type = ErroneousSourceTargetMapper5.class,
|
@Diagnostic(type = ErroneousSourceTargetMapper5.class,
|
||||||
kind = javax.tools.Diagnostic.Kind.ERROR,
|
kind = javax.tools.Diagnostic.Kind.ERROR,
|
||||||
line = 16,
|
line = 16,
|
||||||
messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper"
|
messageRegExp = "No target bean properties found: can't map property "
|
||||||
|
+ "\"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper"
|
||||||
+ "<org.mapstruct.ap.test.selection.generics.TypeC> fooWildCardSuperTypeCFailure\" to"
|
+ "<org.mapstruct.ap.test.selection.generics.TypeC> fooWildCardSuperTypeCFailure\" to"
|
||||||
+ " \"org.mapstruct.ap.test.selection.generics.TypeC fooWildCardSuperTypeCFailure\"")
|
+ " \"org.mapstruct.ap.test.selection.generics.TypeC fooWildCardSuperTypeCFailure\"")
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user