#1001 Dotted error messages

This commit is contained in:
navpil 2016-12-22 09:55:46 +02:00
parent ba20dc5700
commit 32738251e3
42 changed files with 1581 additions and 50 deletions

View File

@ -598,15 +598,12 @@ public class BeanMappingMethod extends MappingMethod {
}
else {
ForgedMethodHistory history = forgedMethod.getHistory();
while ( history.getPrevHistory() != null ) {
history = history.getPrevHistory();
}
ctx.getMessager().printMessage(
this.method.getExecutable(),
Message.PROPERTYMAPPING_MAPPING_NOT_FOUND,
history.getSourceElement(),
history.createSourcePropertyErrorMessage(),
history.getTargetType(),
history.getTargetPropertyName(),
history.createTargetPropertyName(),
history.getTargetType(),
history.getSourceType()
);

View File

@ -185,7 +185,14 @@ public abstract class ContainerMappingMethodBuilder<B extends ContainerMappingMe
method.getMapperConfiguration(),
method.getExecutable(),
method.getContextParameters(),
forgedMethodHistory
new ForgedMethodHistory( forgedMethodHistory,
Strings.stubPropertyName( sourceRHS.getSourceType().getName() ),
Strings.stubPropertyName( targetType.getName() ),
sourceRHS.getSourceType(),
targetType,
false,
sourceRHS.getSourceErrorMessagePart()
)
);
Assignment assignment = new MethodReference(

View File

@ -200,7 +200,14 @@ public class MapMappingMethod extends MappingMethod {
method.getMapperConfiguration(),
method.getExecutable(),
method.getContextParameters(),
history
new ForgedMethodHistory( history,
Strings.stubPropertyName( sourceRHS.getSourceType().getName() ),
Strings.stubPropertyName( targetType.getName() ),
sourceRHS.getSourceType(),
targetType,
true,
sourceRHS.getSourceErrorMessagePart()
)
);
Assignment assignment = new MethodReference(

View File

@ -554,7 +554,7 @@ public class PropertyMapping extends ModelElement {
private Assignment forgeWithElementMapping(Type sourceType, Type targetType, SourceRHS source,
ExecutableElement element, ContainerMappingMethodBuilder<?, ? extends ContainerMappingMethod> builder) {
ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element );
ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element, "[]" );
ContainerMappingMethod iterableMappingMethod = builder
.mappingContext( ctx )
@ -591,7 +591,7 @@ public class PropertyMapping extends ModelElement {
}
private ForgedMethod prepareForgedMethod(Type sourceType, Type targetType, SourceRHS source,
ExecutableElement element) {
ExecutableElement element, String suffix) {
String name = getName( sourceType, targetType );
name = Strings.getSaveVariableName( name, ctx.getNamesOfMappingsToGenerate() );
@ -604,19 +604,14 @@ public class PropertyMapping extends ModelElement {
config,
element,
method.getContextParameters(),
new ForgedMethodHistory( getForgedMethodHistory( source ),
source.getSourceErrorMessagePart(),
targetPropertyName,
source.getSourceType(),
targetType
)
getForgedMethodHistory( source, suffix )
);
}
private Assignment forgeMapMapping(Type sourceType, Type targetType, SourceRHS source,
ExecutableElement element) {
ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element );
ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element, "{}" );
MapMappingMethod.Builder builder = new MapMappingMethod.Builder();
MapMappingMethod mapMappingMethod = builder
@ -669,13 +664,17 @@ public class PropertyMapping extends ModelElement {
}
private ForgedMethodHistory getForgedMethodHistory(SourceRHS sourceRHS) {
return getForgedMethodHistory( sourceRHS, "" );
}
private ForgedMethodHistory getForgedMethodHistory(SourceRHS sourceRHS, String suffix) {
ForgedMethodHistory history = null;
if ( method instanceof ForgedMethod ) {
ForgedMethod method = (ForgedMethod) this.method;
history = method.getHistory();
}
return new ForgedMethodHistory( history, sourceRHS.getSourceErrorMessagePart(),
targetPropertyName, sourceRHS.getSourceType(), targetType
return new ForgedMethodHistory( history, getSourceElementName() + suffix,
targetPropertyName + suffix, sourceRHS.getSourceType(), targetType, true, "property"
);
}
@ -694,6 +693,20 @@ public class PropertyMapping extends ModelElement {
return builder.toString();
}
private String getSourceElementName() {
Parameter sourceParam = sourceReference.getParameter();
List<PropertyEntry> propertyEntries = sourceReference.getPropertyEntries();
if ( propertyEntries.isEmpty() ) {
return sourceParam.getName();
}
else if ( propertyEntries.size() == 1 ) {
PropertyEntry propertyEntry = propertyEntries.get( 0 );
return propertyEntry.getName();
}
else {
return Strings.join( sourceReference.getElementNames(), "." );
}
}
}
public static class ConstantMappingBuilder extends MappingBuilderBase<ConstantMappingBuilder> {

View File

@ -19,6 +19,7 @@
package org.mapstruct.ap.internal.model.source;
import org.mapstruct.ap.internal.model.common.Type;
import org.mapstruct.ap.internal.util.Strings;
/**
* Keeps the context where the ForgedMethod is generated, especially handy with nested forged methods
@ -32,22 +33,18 @@ public class ForgedMethodHistory {
private final String targetPropertyName;
private final Type targetType;
private final Type sourceType;
private final boolean usePropertyNames;
private String elementType;
public ForgedMethodHistory(ForgedMethodHistory history, String sourceElement, String targetPropertyName,
Type sourceType, Type targetType) {
Type sourceType, Type targetType, boolean usePropertyNames, String elementType) {
prevHistory = history;
this.sourceElement = sourceElement;
this.targetPropertyName = targetPropertyName;
this.sourceType = sourceType;
this.targetType = targetType;
}
public String getSourceElement() {
return sourceElement;
}
public String getTargetPropertyName() {
return targetPropertyName;
this.usePropertyNames = usePropertyNames;
this.elementType = elementType;
}
public Type getTargetType() {
@ -58,8 +55,77 @@ public class ForgedMethodHistory {
return sourceType;
}
public ForgedMethodHistory getPrevHistory() {
return prevHistory;
public String createSourcePropertyErrorMessage() {
return conditionallyCapitalizedElementType() + " \"" + getSourceType() + " " +
stripBrackets( getDottedSourceElement() ) + "\"";
}
/**
* Capitalization mostly matters to avoid the funny "Can't map map key" message. However it's irrelevant for the
* "Can't map property" message.
*
* @return capitalized or non-capitalized element type
*/
private String conditionallyCapitalizedElementType() {
if ( "property".equals( elementType ) ) {
return elementType;
}
else {
return Strings.capitalize( elementType );
}
}
public String createTargetPropertyName() {
return stripBrackets( getDottedTargetPropertyName() );
}
private String getDottedSourceElement() {
if ( prevHistory == null ) {
return sourceElement;
}
else {
if ( usePropertyNames ) {
return getCorrectDottedPath( prevHistory.getDottedSourceElement(), sourceElement );
}
else {
return prevHistory.getDottedSourceElement();
}
}
}
private String getDottedTargetPropertyName() {
if ( prevHistory == null ) {
return targetPropertyName;
}
else {
if ( usePropertyNames ) {
return getCorrectDottedPath( prevHistory.getDottedTargetPropertyName(), targetPropertyName );
}
else {
return prevHistory.getDottedTargetPropertyName();
}
}
}
private String getCorrectDottedPath(String previousPath, String currentProperty) {
if ( "map key".equals( elementType ) ) {
return stripBrackets( previousPath ) + "{:key}";
}
else if ( "map value".equals( elementType ) ) {
return stripBrackets( previousPath ) + "{:value}";
}
else {
return previousPath + "." + currentProperty;
}
}
private String stripBrackets(String dottedName) {
if ( dottedName.endsWith( "[]" ) || dottedName.endsWith( "{}" ) ) {
dottedName = dottedName.substring( 0, dottedName.length() - 2 );
}
return dottedName;
}
}

View File

@ -177,6 +177,17 @@ public class Strings {
return identifier.replace( "[]", "Array" );
}
/**
* Returns a stub property name from full class name by stripping away the package and decapitalizing the name
* For example will return {@code fooBar} for {@code com.foo.bar.baz.FooBar} class name
*
* @param fullyQualifiedName fully qualified class name, such as com.foo.bar.baz.FooBar
* @return stup property name, such as fooBar
*/
public static String stubPropertyName(String fullyQualifiedName) {
return Strings.decapitalize( fullyQualifiedName.substring( fullyQualifiedName.lastIndexOf( '.' ) + 1 ) );
}
/**
* It removes the dots from the name and creates an {@link Iterable} from them.
*

View File

@ -66,8 +66,8 @@ public class ErroneousCollectionMappingTest {
kind = Kind.ERROR,
line = 26,
messageRegExp = "Can't map property \"java.util.List<java.lang.String> strings\" to \"int strings\". "
+ "Consider to declare/implement a mapping method: \"int map\\(java.util.List<java.lang.String>"
+ " value\\)\"")
+ "Consider to declare/implement a mapping method: \"int map\\(java.util.List<java.lang.String>"
+ " value\\)\"")
}
)
public void shouldFailToGenerateImplementationBetweenCollectionAndPrimitive() {
@ -115,8 +115,9 @@ public class ErroneousCollectionMappingTest {
@Diagnostic(type = ErroneousCollectionNoElementMappingFound.class,
kind = Kind.ERROR,
line = 37,
messageRegExp = "Can't map .*AttributedString to .*String. " +
"Consider to implement a mapping method: \".*String map(.*AttributedString value)")
messageRegExp =
"Can't map Collection element \".*AttributedString attributedString\" to \".*String string\". " +
"Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)")
}
)
public void shouldFailOnNoElementMappingFound() {
@ -131,8 +132,8 @@ public class ErroneousCollectionMappingTest {
@Diagnostic(type = ErroneousCollectionNoKeyMappingFound.class,
kind = Kind.ERROR,
line = 37,
messageRegExp = "Can't map .*AttributedString to .*String. " +
"Consider to implement a mapping method: \".*String map(.*AttributedString value)")
messageRegExp = "Can't map Map key \".*AttributedString attributedString\" to \".*String string\". " +
"Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)")
}
)
public void shouldFailOnNoKeyMappingFound() {
@ -147,8 +148,8 @@ public class ErroneousCollectionMappingTest {
@Diagnostic(type = ErroneousCollectionNoValueMappingFound.class,
kind = Kind.ERROR,
line = 37,
messageRegExp = "Can't map .*AttributedString to .*String. " +
"Consider to implement a mapping method: \".*String map(.*AttributedString value)")
messageRegExp = "Can't map Map value \".*AttributedString attributedString\" to \".*String string\". " +
"Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)")
}
)
public void shouldFailOnNoValueMappingFound() {

View File

@ -100,7 +100,7 @@ public class CollectionMappingTest {
@Diagnostic(type = ErroneousCollectionNonMappableSetMapper.class,
kind = Kind.ERROR,
line = 30,
messageRegExp = "Can't map property \".* nonMappableSet\" to \".* nonMappableSet\". "
messageRegExp = "Can't map Collection element \".* nonMappableSet\" to \".* nonMappableSet\". "
+ "Consider to declare/implement a mapping method: .*."),
}
)
@ -120,7 +120,7 @@ public class CollectionMappingTest {
@Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class,
kind = Kind.ERROR,
line = 30,
messageRegExp = "Can't map property \".* nonMappableMap\" to \".* nonMappableMap\". "
messageRegExp = "Can't map Map key \".* nonMappableMap\\{:key\\}\" to \".* nonMappableMap\\{:key\\}\". "
+ "Consider to declare/implement a mapping method: .*."),
}
)

View File

@ -115,8 +115,8 @@ public class ErroneousStreamMappingTest {
@Diagnostic(type = ErroneousStreamToStreamNoElementMappingFound.class,
kind = Kind.ERROR,
line = 36,
messageRegExp = "Can't map .*AttributedString to .*String. " +
"Consider to implement a mapping method: \".*String map(.*AttributedString value)")
messageRegExp = "Can't map Stream element .*AttributedString attributedString\" to .*String string\"." +
" Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)")
}
)
public void shouldFailOnNoElementMappingFoundForStreamToStream() {
@ -130,8 +130,8 @@ public class ErroneousStreamMappingTest {
@Diagnostic(type = ErroneousListToStreamNoElementMappingFound.class,
kind = Kind.ERROR,
line = 37,
messageRegExp = "Can't map .*AttributedString to .*String. " +
"Consider to implement a mapping method: \".*String map(.*AttributedString value)")
messageRegExp = "Can't map .*AttributedString attributedString\" to .*String string\". " +
"Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)")
}
)
public void shouldFailOnNoElementMappingFoundForListToStream() {
@ -145,8 +145,8 @@ public class ErroneousStreamMappingTest {
@Diagnostic(type = ErroneousStreamToListNoElementMappingFound.class,
kind = Kind.ERROR,
line = 37,
messageRegExp = "Can't map .*AttributedString to .*String. " +
"Consider to implement a mapping method: \".*String map(.*AttributedString value)")
messageRegExp = "Can't map Stream element .*AttributedString attributedString\" to .*String string\"." +
" Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)")
}
)
public void shouldFailOnNoElementMappingFoundForStreamToList() {

View File

@ -83,7 +83,7 @@ public class ForgedStreamMappingTest {
@Diagnostic(type = ErroneousStreamNonMappableStreamMapper.class,
kind = Kind.ERROR,
line = 30,
messageRegExp = "Can't map property \".* nonMappableStream\" to \".* nonMappableStream\". "
messageRegExp = "Can't map Stream element \".* nonMappableStream\" to \".* nonMappableStream\". "
+ "Consider to declare/implement a mapping method: .*."),
}
)

View File

@ -0,0 +1,186 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.test.nestedbeans.erroneous.Computer;
import org.mapstruct.ap.test.nestedbeans.erroneous.ComputerDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.Dictionary;
import org.mapstruct.ap.test.nestedbeans.erroneous.DictionaryDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.ForeignWord;
import org.mapstruct.ap.test.nestedbeans.erroneous.ForeignWordDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.Cat;
import org.mapstruct.ap.test.nestedbeans.erroneous.CatDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.Info;
import org.mapstruct.ap.test.nestedbeans.erroneous.InfoDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableCollectionElementPropertyMapper;
import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepListMapper;
import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepMapKeyMapper;
import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepMapValueMapper;
import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableValuePropertyMapper;
import org.mapstruct.ap.test.nestedbeans.erroneous.UserDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.User;
import org.mapstruct.ap.test.nestedbeans.erroneous.WheelDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.Wheel;
import org.mapstruct.ap.test.nestedbeans.erroneous.Car;
import org.mapstruct.ap.test.nestedbeans.erroneous.CarDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.House;
import org.mapstruct.ap.test.nestedbeans.erroneous.HouseDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.Color;
import org.mapstruct.ap.test.nestedbeans.erroneous.ColorDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.Roof;
import org.mapstruct.ap.test.nestedbeans.erroneous.RoofDto;
import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepNestingMapper;
import org.mapstruct.ap.test.nestedbeans.erroneous.Word;
import org.mapstruct.ap.test.nestedbeans.erroneous.WordDto;
import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic;
import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
@WithClasses({
Car.class, CarDto.class, Color.class, ColorDto.class,
House.class, HouseDto.class, Roof.class, RoofDto.class,
User.class, UserDto.class, Wheel.class, WheelDto.class,
Dictionary.class, DictionaryDto.class, Word.class, WordDto.class,
ForeignWord.class, ForeignWordDto.class,
Computer.class, ComputerDto.class,
Cat.class, CatDto.class, Info.class, InfoDto.class
})
@RunWith(AnnotationProcessorTestRunner.class)
public class DottedErrorMessageTest {
private static final String PROPERTY = "property";
private static final String COLLECTION_ELEMENT = "Collection element";
private static final String MAP_KEY = "Map key";
private static final String MAP_VALUE = "Map value";
@Test
@WithClasses({
UnmappableDeepNestingMapper.class
})
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = UnmappableDeepNestingMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 26,
messageRegExp = "Can't map " + PROPERTY +
" \".*Color house\\.roof\\.color\" to \".*house\\.roof\\.color\"\\. " +
"Consider to declare/implement a mapping method: \".*ColorDto map\\(.*Color value\\)\"\\.")
}
)
public void testDeepNestedBeans() {
}
@Test
@WithClasses({
UnmappableDeepListMapper.class
})
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = UnmappableDeepListMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 26,
messageRegExp = "Can't map " + COLLECTION_ELEMENT +
" \".*Wheel car\\.wheels\" to \".*car\\.wheels\"\\. " +
"Consider to declare/implement a mapping method: \".*WheelDto map\\(.*Wheel value\\)\"\\.")
}
)
public void testIterables() {
}
@Test
@WithClasses({
UnmappableDeepMapKeyMapper.class
})
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = UnmappableDeepMapKeyMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 26,
messageRegExp = "Can't map " + MAP_KEY +
" \".*Word dictionary\\.wordMap\\{:key\\}\" to \".*dictionary\\.wordMap\\{:key\\}\"\\. " +
"Consider to declare/implement a mapping method: \".*WordDto map\\(.*Word value\\)\"\\.")
}
)
public void testMapKeys() {
}
@Test
@WithClasses({
UnmappableDeepMapValueMapper.class
})
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = UnmappableDeepMapValueMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 26,
messageRegExp = "Can't map " + MAP_VALUE +
" \".*ForeignWord dictionary\\.wordMap\\{:value\\}\" " +
"to \".*dictionary\\.wordMap\\{:value\\}\"\\. " +
"Consider to declare/implement a mapping method: " +
"\".*ForeignWordDto map\\(.*ForeignWord value\\)\"\\.")
}
)
public void testMapValues() {
}
@Test
@WithClasses({
UnmappableCollectionElementPropertyMapper.class
})
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = UnmappableCollectionElementPropertyMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 26,
messageRegExp = "Can't map " + PROPERTY +
" \".*Info computers\\[\\].info\" to \".*computers\\[\\].info\"\\. " +
"Consider to declare/implement a mapping method: \".*InfoDto map\\(.*Info value\\)\"\\.")
}
)
public void testCollectionElementProperty() {
}
@Test
@WithClasses({
UnmappableValuePropertyMapper.class
})
@ExpectedCompilationOutcome(
value = CompilationResult.FAILED,
diagnostics = {
@Diagnostic(type = UnmappableValuePropertyMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 26,
messageRegExp = "Can't map " + PROPERTY +
" \".*Info catNameMap\\{:value\\}.info\" to \".*catNameMap\\{:value\\}.info\"\\. " +
"Consider to declare/implement a mapping method: \".*InfoDto map\\(.*Info value\\)\"\\.")
}
)
public void testMapValueProperty() {
}
}

View File

@ -0,0 +1,53 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import java.util.List;
public class Car {
private String name;
private int year;
private List<Wheel> wheels;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public List<Wheel> getWheels() {
return wheels;
}
public void setWheels(List<Wheel> wheels) {
this.wheels = wheels;
}
}

View File

@ -0,0 +1,53 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import java.util.List;
public class CarDto {
private String name;
private int year;
private List<WheelDto> wheels;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public List<WheelDto> getWheels() {
return wheels;
}
public void setWheels(List<WheelDto> wheels) {
this.wheels = wheels;
}
}

View File

@ -0,0 +1,33 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Cat {
private Info info;
public Info getInfo() {
return info;
}
public void setInfo(Info info) {
this.info = info;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class CatDto {
private InfoDto info;
public InfoDto getInfo() {
return info;
}
public void setInfo(InfoDto info) {
this.info = info;
}
}

View File

@ -0,0 +1,38 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Color {
private String cmyk;
public Color() {
}
public Color(String cmyk) {
this.cmyk = cmyk;
}
public String getCmyk() {
return cmyk;
}
public void setCmyk(String cmyk) {
this.cmyk = cmyk;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class ColorDto {
private String rgb;
public String getRgb() {
return rgb;
}
public void setRgb(String rgb) {
this.rgb = rgb;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Computer {
private Info info;
public Info getInfo() {
return info;
}
public void setInfo(Info info) {
this.info = info;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class ComputerDto {
private InfoDto info;
public InfoDto getInfo() {
return info;
}
public void setInfo(InfoDto info) {
this.info = info;
}
}

View File

@ -0,0 +1,35 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import java.util.Map;
public class Dictionary {
private Map<Word, ForeignWord> wordMap;
public Map<Word, ForeignWord> getWordMap() {
return wordMap;
}
public void setWordMap(
Map<Word, ForeignWord> wordMap) {
this.wordMap = wordMap;
}
}

View File

@ -0,0 +1,35 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import java.util.Map;
public class DictionaryDto {
private Map<WordDto, ForeignWordDto> wordMap;
public Map<WordDto, ForeignWordDto> getWordMap() {
return wordMap;
}
public void setWordMap(
Map<WordDto, ForeignWordDto> wordMap) {
this.wordMap = wordMap;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class ForeignWord {
private String meaning;
public String getMeaning() {
return meaning;
}
public void setMeaning(String meaning) {
this.meaning = meaning;
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class ForeignWordDto {
private String pronunciation;
public String getPronunciation() {
return pronunciation;
}
public void setPronunciation(String pronunciation) {
this.pronunciation = pronunciation;
}
}

View File

@ -0,0 +1,51 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class House {
private String name;
private int year;
private Roof roof;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public Roof getRoof() {
return roof;
}
public void setRoof(Roof roof) {
this.roof = roof;
}
}

View File

@ -0,0 +1,51 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class HouseDto {
private String name;
private int year;
private RoofDto roof;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public RoofDto getRoof() {
return roof;
}
public void setRoof(RoofDto roof) {
this.roof = roof;
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Info {
private String size;
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class InfoDto {
private String color;
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Roof {
private Color color;
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class RoofDto {
private ColorDto color;
public ColorDto getColor() {
return color;
}
public void setColor(ColorDto color) {
this.color = color;
}
}

View File

@ -0,0 +1,43 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import org.mapstruct.Mapper;
@Mapper
public abstract class UnmappableCollectionElementPropertyMapper {
abstract UserDto userToUserDto(User user);
public HouseDto map(House house) {
return new HouseDto();
}
public CarDto map(Car carDto) {
return new CarDto();
}
public DictionaryDto map(Dictionary dictionary) {
return new DictionaryDto();
}
public CatDto map(Cat cat) {
return new CatDto();
}
}

View File

@ -0,0 +1,43 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import org.mapstruct.Mapper;
@Mapper
public abstract class UnmappableDeepListMapper {
abstract UserDto userToUserDto(User user);
public HouseDto map(House house) {
return new HouseDto();
}
public DictionaryDto map(Dictionary dictionary) {
return new DictionaryDto();
}
public ComputerDto map(Computer computer) {
return new ComputerDto();
}
public CatDto map(Cat cat) {
return new CatDto();
}
}

View File

@ -0,0 +1,48 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import org.mapstruct.Mapper;
@Mapper
public abstract class UnmappableDeepMapKeyMapper {
abstract UserDto userToUserDto(User user);
public CarDto map(Car carDto) {
return new CarDto();
}
public HouseDto map(House house) {
return new HouseDto();
}
public ForeignWordDto map(ForeignWord word) {
return new ForeignWordDto();
}
public ComputerDto map(Computer computer) {
return new ComputerDto();
}
public CatDto map(Cat cat) {
return new CatDto();
}
}

View File

@ -0,0 +1,48 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import org.mapstruct.Mapper;
@Mapper
public abstract class UnmappableDeepMapValueMapper {
abstract UserDto userToUserDto(User user);
public CarDto map(Car carDto) {
return new CarDto();
}
public HouseDto map(House house) {
return new HouseDto();
}
public WordDto map(Word word) {
return new WordDto();
}
public ComputerDto map(Computer computer) {
return new ComputerDto();
}
public CatDto map(Cat cat) {
return new CatDto();
}
}

View File

@ -0,0 +1,44 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import org.mapstruct.Mapper;
@Mapper
public abstract class UnmappableDeepNestingMapper {
abstract UserDto userToUserDto(User user);
public CarDto map(Car carDto) {
return new CarDto();
}
public DictionaryDto map(Dictionary dictionary) {
return new DictionaryDto();
}
public ComputerDto map(Computer computer) {
return new ComputerDto();
}
public CatDto map(Cat cat) {
return new CatDto();
}
}

View File

@ -0,0 +1,43 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import org.mapstruct.Mapper;
@Mapper
public abstract class UnmappableValuePropertyMapper {
abstract UserDto userToUserDto(User user);
public HouseDto map(House house) {
return new HouseDto();
}
public CarDto map(Car carDto) {
return new CarDto();
}
public DictionaryDto map(Dictionary dictionary) {
return new DictionaryDto();
}
public ComputerDto map(Computer computer) {
return new ComputerDto();
}
}

View File

@ -0,0 +1,85 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import java.util.List;
import java.util.Map;
public class User {
private String name;
//list of Wheels inside
private Car car;
//deep nesting inside Roof->Color
private House house;
//unmappable keys/values
private Dictionary dictionary;
//collection element's property can't be mapped
private List<Computer> computers;
//map value property can't be mapped
private Map<String, Cat> catNameMap;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Car getCar() {
return car;
}
public void setCar(Car car) {
this.car = car;
}
public House getHouse() {
return house;
}
public void setHouse(House house) {
this.house = house;
}
public Dictionary getDictionary() {
return dictionary;
}
public void setDictionary(Dictionary dictionary) {
this.dictionary = dictionary;
}
public List<Computer> getComputers() {
return computers;
}
public void setComputers(List<Computer> computers) {
this.computers = computers;
}
public Map<String, Cat> getCatNameMap() {
return catNameMap;
}
public void setCatNameMap(Map<String, Cat> catNameMap) {
this.catNameMap = catNameMap;
}
}

View File

@ -0,0 +1,81 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
import java.util.List;
import java.util.Map;
public class UserDto {
private String name;
private CarDto car;
private HouseDto house;
private DictionaryDto dictionary;
private List<ComputerDto> computers;
private Map<String, CatDto> catNameMap;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public CarDto getCar() {
return car;
}
public void setCar(CarDto car) {
this.car = car;
}
public HouseDto getHouse() {
return house;
}
public void setHouse(HouseDto house) {
this.house = house;
}
public DictionaryDto getDictionary() {
return dictionary;
}
public void setDictionary(DictionaryDto dictionary) {
this.dictionary = dictionary;
}
public List<ComputerDto> getComputers() {
return computers;
}
public void setComputers(List<ComputerDto> computers) {
this.computers = computers;
}
public Map<String, CatDto> getCatNameMap() {
return catNameMap;
}
public void setCatNameMap(
Map<String, CatDto> catNameMap) {
this.catNameMap = catNameMap;
}
}

View File

@ -0,0 +1,41 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Wheel {
private boolean front;
private boolean right;
public boolean isFront() {
return front;
}
public void setFront(boolean front) {
this.front = front;
}
public boolean isRight() {
return right;
}
public void setRight(boolean right) {
this.right = right;
}
}

View File

@ -0,0 +1,40 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class WheelDto {
private boolean front;
private boolean left;
public boolean isFront() {
return front;
}
public void setFront(boolean front) {
this.front = front;
}
public boolean isLeft() {
return left;
}
public void setLeft(boolean left) {
this.left = left;
}
}

View File

@ -0,0 +1,32 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class Word {
private String meaning;
public String getMeaning() {
return meaning;
}
public void setMeaning(String meaning) {
this.meaning = meaning;
}
}

View File

@ -0,0 +1,31 @@
/**
* Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.ap.test.nestedbeans.erroneous;
public class WordDto {
private String pronunciation;
public String getPronunciation() {
return pronunciation;
}
public void setPronunciation(String pronunciation) {
this.pronunciation = pronunciation;
}
}

View File

@ -168,10 +168,10 @@ public class ConversionTest {
@Diagnostic(type = ErroneousSourceTargetMapper6.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 29,
messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper"
+ "<java.lang.String> foo\" to"
+ " \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" +
"<org.mapstruct.ap.test.selection.generics.TypeA> foo\"")
messageRegExp = "Can't map property \"java.lang.String "
+ "foo\\.wrapped\" to"
+ " \"org.mapstruct.ap.test.selection.generics.TypeA " +
"foo\\.wrapped\"")
})
public void shouldFailOnNonMatchingWildCards() {
}