diff --git a/processor/src/main/java/org/mapstruct/ap/model/IterableMappingMethod.java b/processor/src/main/java/org/mapstruct/ap/model/IterableMappingMethod.java index 2daf00136..d40b341a5 100644 --- a/processor/src/main/java/org/mapstruct/ap/model/IterableMappingMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/model/IterableMappingMethod.java @@ -29,6 +29,7 @@ import org.mapstruct.ap.model.assignment.LocalVarWrapper; import org.mapstruct.ap.model.assignment.SetterWrapper; import org.mapstruct.ap.model.common.Parameter; import org.mapstruct.ap.model.common.Type; +import org.mapstruct.ap.model.source.ForgedMethod; import org.mapstruct.ap.model.source.Method; import org.mapstruct.ap.prism.NullValueMappingStrategyPrism; import org.mapstruct.ap.util.Message; @@ -119,7 +120,12 @@ public class IterableMappingMethod extends MappingMethod { if ( assignment == null ) { ctx.getMessager().printMessage( method.getExecutable(), Message.ITERABLEMAPPING_MAPPING_NOT_FOUND ); } - + else { + if ( method instanceof ForgedMethod ) { + ForgedMethod forgedMethod = (ForgedMethod) method; + forgedMethod.addThrownTypes( assignment.getExceptionTypes() ); + } + } // target accessor is setter, so decorate assignment as setter if ( resultType.isArrayType() ) { assignment = new LocalVarWrapper( assignment, method.getThrownTypes() ); diff --git a/processor/src/main/java/org/mapstruct/ap/model/MapMappingMethod.java b/processor/src/main/java/org/mapstruct/ap/model/MapMappingMethod.java index 37c3ad15c..4321d3ac9 100644 --- a/processor/src/main/java/org/mapstruct/ap/model/MapMappingMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/model/MapMappingMethod.java @@ -27,6 +27,7 @@ import org.mapstruct.ap.model.assignment.Assignment; import org.mapstruct.ap.model.assignment.LocalVarWrapper; import org.mapstruct.ap.model.common.Parameter; import org.mapstruct.ap.model.common.Type; +import org.mapstruct.ap.model.source.ForgedMethod; import org.mapstruct.ap.model.source.Method; import org.mapstruct.ap.prism.NullValueMappingStrategyPrism; import org.mapstruct.ap.util.Message; @@ -150,6 +151,16 @@ public class MapMappingMethod extends MappingMethod { false ); + if ( method instanceof ForgedMethod ) { + ForgedMethod forgedMethod = (ForgedMethod) method; + if ( keyAssignment != null ) { + forgedMethod.addThrownTypes( keyAssignment.getExceptionTypes() ); + } + if ( valueAssignment != null ) { + forgedMethod.addThrownTypes( valueAssignment.getExceptionTypes() ); + } + } + if ( valueAssignment == null ) { ctx.getMessager().printMessage( method.getExecutable(), Message.MAPMAPPING_VALUE_MAPPING_NOT_FOUND ); } diff --git a/processor/src/main/java/org/mapstruct/ap/model/source/ForgedMethod.java b/processor/src/main/java/org/mapstruct/ap/model/source/ForgedMethod.java index bda03d901..cbc40dae4 100644 --- a/processor/src/main/java/org/mapstruct/ap/model/source/ForgedMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/model/source/ForgedMethod.java @@ -20,7 +20,6 @@ package org.mapstruct.ap.model.source; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import javax.lang.model.element.ExecutableElement; @@ -41,6 +40,7 @@ public class ForgedMethod implements Method { private final Type returnType; private final String name; private final ExecutableElement positionHintElement; + private final List thrownTypes; /** * Creates a new forged method with the given name. @@ -55,6 +55,7 @@ public class ForgedMethod implements Method { String sourceParamSafeName = Strings.getSaveVariableName( sourceParamName ); this.parameters = Arrays.asList( new Parameter( sourceParamSafeName, sourceType ) ); this.returnType = targetType; + this.thrownTypes = new ArrayList(); this.name = name; this.positionHintElement = positionHintElement; } @@ -67,6 +68,7 @@ public class ForgedMethod implements Method { public ForgedMethod(String name, ForgedMethod forgedMethod) { this.parameters = forgedMethod.parameters; this.returnType = forgedMethod.returnType; + this.thrownTypes = new ArrayList(); this.positionHintElement = forgedMethod.positionHintElement; this.name = name; } @@ -131,7 +133,16 @@ public class ForgedMethod implements Method { @Override public List getThrownTypes() { - return Collections.emptyList(); + return thrownTypes; + } + + public void addThrownTypes(List thrownTypesToAdd) { + for ( Type thrownType : thrownTypesToAdd ) { + // make sure there are no duplicates coming from the keyAssignment thrown types. + if ( !thrownTypes.contains( thrownType ) ) { + thrownTypes.add( thrownType ); + } + } } @Override diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Issue513Mapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Issue513Mapper.java new file mode 100644 index 000000000..c68dfb2c3 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Issue513Mapper.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface Issue513Mapper { + + Issue513Mapper INSTANCE = Mappers.getMapper( Issue513Mapper.class ); + + + Target map(Source source) throws MappingException, MappingValueException, MappingKeyException; + + TargetElement mapElement(SourceElement source) throws MappingException; + + TargetKey mapKey(SourceKey source) throws MappingException, MappingKeyException; + + TargetValue mapValue(SourceValue source) throws MappingException, MappingValueException; + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Issue513Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Issue513Test.java new file mode 100644 index 000000000..39d809e94 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Issue513Test.java @@ -0,0 +1,108 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +import java.util.Arrays; +import java.util.HashMap; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; + +/** + * Reproducer for https://github.com/mapstruct/mapstruct/issues/513. + * + * @author Sjaak Derksen + */ +@IssueKey( "513" ) + @WithClasses( { + Issue513Mapper.class, + Source.class, + Target.class, + SourceElement.class, + TargetElement.class, + SourceKey.class, + TargetKey.class, + SourceValue.class, + TargetValue.class, + MappingException.class, + MappingKeyException.class, + MappingValueException.class + } ) +@RunWith(AnnotationProcessorTestRunner.class) +public class Issue513Test { + + @Test( expected = MappingException.class ) + public void shouldThrowMappingException() throws Exception { + + Source source = new Source(); + SourceElement sourceElement = new SourceElement(); + sourceElement.setValue( "test" ); + source.setCollection( Arrays.asList( new SourceElement[]{ sourceElement } ) ); + + Issue513Mapper.INSTANCE.map( source ); + + } + + @Test( expected = MappingKeyException.class ) + public void shouldThrowMappingKeyException() throws Exception { + + Source source = new Source(); + SourceKey sourceKey = new SourceKey(); + sourceKey.setValue( MappingKeyException.class.getSimpleName() ); + SourceValue sourceValue = new SourceValue(); + HashMap map = new HashMap(); + map.put( sourceKey, sourceValue ); + source.setMap( map ); + + Issue513Mapper.INSTANCE.map( source ); + + } + + @Test( expected = MappingValueException.class ) + public void shouldThrowMappingValueException() throws Exception { + + Source source = new Source(); + SourceKey sourceKey = new SourceKey(); + SourceValue sourceValue = new SourceValue(); + sourceValue.setValue( MappingValueException.class.getSimpleName() ); + HashMap map = new HashMap(); + map.put( sourceKey, sourceValue ); + source.setMap( map ); + + Issue513Mapper.INSTANCE.map( source ); + + } + + @Test( expected = MappingException.class ) + public void shouldThrowMappingCommonException() throws Exception { + + Source source = new Source(); + SourceKey sourceKey = new SourceKey(); + SourceValue sourceValue = new SourceValue(); + sourceValue.setValue( MappingException.class.getSimpleName() ); + HashMap map = new HashMap(); + map.put( sourceKey, sourceValue ); + source.setMap( map ); + + Issue513Mapper.INSTANCE.map( source ); + + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingException.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingException.java new file mode 100644 index 000000000..0b37d7710 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingException.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +/** + * + * @author Sjaak Derksen + */ +public class MappingException extends Exception { + + + public MappingException() { + } + + public MappingException(String msg) { + super( msg ); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingKeyException.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingKeyException.java new file mode 100644 index 000000000..429ab2ab3 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingKeyException.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +/** + * + * @author Sjaak Derksen + */ +public class MappingKeyException extends Exception { + + + public MappingKeyException() { + } + + public MappingKeyException(String msg) { + super( msg ); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingValueException.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingValueException.java new file mode 100644 index 000000000..1358b7cf8 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/MappingValueException.java @@ -0,0 +1,34 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +/** + * + * @author Sjaak Derksen + */ +public class MappingValueException extends Exception { + + + public MappingValueException() { + } + + public MappingValueException(String msg) { + super( msg ); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Source.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Source.java new file mode 100644 index 000000000..c70fec8f5 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Source.java @@ -0,0 +1,50 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +import java.util.Collection; +import java.util.Map; + +/** + * + * @author Sjaak Derksen + */ +public class Source { + + private Collection collection; + private Map map; + + + public Collection getCollection() { + return collection; + } + + public void setCollection(Collection collection) { + this.collection = collection; + } + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceElement.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceElement.java new file mode 100644 index 000000000..b985cc6e8 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceElement.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +/** + * + * @author Sjaak Derksen + */ +public class SourceElement { + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceKey.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceKey.java new file mode 100644 index 000000000..f6aa46252 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceKey.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +/** + * + * @author Sjaak Derksen + */ +public class SourceKey { + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceValue.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceValue.java new file mode 100644 index 000000000..2b2fc0995 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/SourceValue.java @@ -0,0 +1,37 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +/** + * + * @author Sjaak Derksen + */ +public class SourceValue { + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Target.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Target.java new file mode 100644 index 000000000..c384e1b56 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/Target.java @@ -0,0 +1,49 @@ +/** + * Copyright 2012-2015 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.bugs._513; + +import java.util.Collection; +import java.util.Map; + +/** + * + * @author Sjaak Derksen + */ +public class Target { + + private Collection collection; + private Map map; + + public Collection getCollection() { + return collection; + } + + public void setCollection( Collection collection ) { + this.collection = collection; + } + + public Map getMap() { + return map; + } + + public void setMap(Map map) { + this.map = map; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetElement.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetElement.java new file mode 100644 index 000000000..3150984b0 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetElement.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012-2015 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.bugs._513; + + +/** + * + * @author Sjaak Derksen + */ +public class TargetElement { + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) throws MappingException { + throw new MappingException(); + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetKey.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetKey.java new file mode 100644 index 000000000..6c7f32bf6 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetKey.java @@ -0,0 +1,43 @@ +/** + * Copyright 2012-2015 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.bugs._513; + + +/** + * + * @author Sjaak Derksen + */ +public class TargetKey { + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) throws MappingException, MappingKeyException { + if ( MappingKeyException.class.getSimpleName().equals( value ) ) { + throw new MappingKeyException(); + } + else if ( MappingException.class.getSimpleName().equals( value ) ) { + throw new MappingException(); + } + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetValue.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetValue.java new file mode 100644 index 000000000..63726457d --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_513/TargetValue.java @@ -0,0 +1,43 @@ +/** + * Copyright 2012-2015 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.bugs._513; + + +/** + * + * @author Sjaak Derksen + */ +public class TargetValue { + + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) throws MappingException, MappingValueException { + if ( MappingValueException.class.getSimpleName().equals( value ) ) { + throw new MappingValueException(); + } + else if ( MappingException.class.getSimpleName().equals( value ) ) { + throw new MappingException(); + } + } + +}