mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#306 IllegalArgumentException due to void type parameter
This commit is contained in:
parent
e9a74d1fc0
commit
3342990387
@ -32,6 +32,7 @@ import javax.lang.model.element.Modifier;
|
|||||||
import javax.lang.model.element.Name;
|
import javax.lang.model.element.Name;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.element.VariableElement;
|
import javax.lang.model.element.VariableElement;
|
||||||
|
import javax.lang.model.type.TypeKind;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.lang.model.util.Elements;
|
import javax.lang.model.util.Elements;
|
||||||
import javax.lang.model.util.Types;
|
import javax.lang.model.util.Types;
|
||||||
@ -72,6 +73,8 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
private final boolean isCollectionType;
|
private final boolean isCollectionType;
|
||||||
private final boolean isMapType;
|
private final boolean isMapType;
|
||||||
private final boolean isImported;
|
private final boolean isImported;
|
||||||
|
private final boolean isVoid;
|
||||||
|
|
||||||
private final List<String> enumConstants;
|
private final List<String> enumConstants;
|
||||||
|
|
||||||
private List<ExecutableElement> getters = null;
|
private List<ExecutableElement> getters = null;
|
||||||
@ -103,6 +106,7 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
this.isCollectionType = isCollectionType;
|
this.isCollectionType = isCollectionType;
|
||||||
this.isMapType = isMapType;
|
this.isMapType = isMapType;
|
||||||
this.isImported = isImported;
|
this.isImported = isImported;
|
||||||
|
this.isVoid = typeMirror.getKind().equals( TypeKind.VOID );
|
||||||
|
|
||||||
if ( isEnumType ) {
|
if ( isEnumType ) {
|
||||||
enumConstants = new ArrayList<String>();
|
enumConstants = new ArrayList<String>();
|
||||||
@ -154,6 +158,10 @@ public class Type extends ModelElement implements Comparable<Type> {
|
|||||||
return isEnumType;
|
return isEnumType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isVoid() {
|
||||||
|
return isVoid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns this type's enum constants in case it is an enum, an empty list otherwise.
|
* Returns this type's enum constants in case it is an enum, an empty list otherwise.
|
||||||
*/
|
*/
|
||||||
|
@ -193,7 +193,10 @@ public class TypeFactory {
|
|||||||
*/
|
*/
|
||||||
public Type classTypeOf(Type type) {
|
public Type classTypeOf(Type type) {
|
||||||
TypeMirror typeToUse;
|
TypeMirror typeToUse;
|
||||||
if ( type.isPrimitive() ) {
|
if ( type.isVoid() ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else if ( type.isPrimitive() ) {
|
||||||
typeToUse = typeUtils.boxedClass( (PrimitiveType) type.getTypeMirror() ).asType();
|
typeToUse = typeUtils.boxedClass( (PrimitiveType) type.getTypeMirror() ).asType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -18,14 +18,27 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.collection.forged;
|
package org.mapstruct.ap.test.collection.forged;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.TargetType;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CollectionMapper {
|
public abstract class CollectionMapper {
|
||||||
|
|
||||||
CollectionMapper INSTANCE = Mappers.getMapper( CollectionMapper.class );
|
public static final CollectionMapper INSTANCE = Mappers.getMapper( CollectionMapper.class );
|
||||||
|
|
||||||
Target sourceToTarget(Source source);
|
public abstract Target sourceToTarget(Source source);
|
||||||
Source targetToSource(Target target);
|
public abstract Source targetToSource(Target target);
|
||||||
|
|
||||||
|
|
||||||
|
// this method is added to reproduce issue 306
|
||||||
|
protected void dummy1( Set<String> arg ) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
|
|
||||||
|
// this method is added to reproduce issue 306
|
||||||
|
protected Set<Long> dummy2( Object object, @TargetType Class clazz ) {
|
||||||
|
throw new RuntimeException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import org.mapstruct.ap.util.Collections;
|
|||||||
*
|
*
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
@IssueKey("4")
|
@IssueKey("4, 306")
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class CollectionMappingTest {
|
public class CollectionMappingTest {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user