diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/MethodReference.java b/processor/src/main/java/org/mapstruct/ap/internal/model/MethodReference.java index 17c862962..2eca50593 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/MethodReference.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/MethodReference.java @@ -26,6 +26,7 @@ import java.util.Set; import org.mapstruct.ap.internal.model.common.Assignment; import org.mapstruct.ap.internal.model.common.ConversionContext; +import org.mapstruct.ap.internal.model.common.ModelElement; import org.mapstruct.ap.internal.model.common.Parameter; import org.mapstruct.ap.internal.model.common.ParameterBinding; import org.mapstruct.ap.internal.model.common.Type; @@ -38,7 +39,10 @@ import org.mapstruct.ap.internal.model.source.builtin.BuiltInMethod; * * @author Gunnar Morling */ -public class MethodReference extends MappingMethod implements Assignment { +public class MethodReference extends ModelElement implements Assignment { + private final String name; + private final List sourceParameters; + private final Type returnType; private final MapperReference declaringMapper; private final Set importTypes; private final List thrownTypes; @@ -62,6 +66,7 @@ public class MethodReference extends MappingMethod implements Assignment { private final Type definingType; private final List parameterBindings; private final Parameter providingParameter; + private final boolean isStatic; /** * Creates a new reference to the given method. @@ -74,8 +79,9 @@ public class MethodReference extends MappingMethod implements Assignment { */ protected MethodReference(Method method, MapperReference declaringMapper, Parameter providingParameter, List parameterBindings) { - super( method ); this.declaringMapper = declaringMapper; + this.sourceParameters = Parameter.getSourceParameters( method.getParameters() ); + this.returnType = method.getReturnType(); this.providingParameter = providingParameter; this.parameterBindings = parameterBindings; this.contextParam = null; @@ -93,10 +99,13 @@ public class MethodReference extends MappingMethod implements Assignment { this.thrownTypes = method.getThrownTypes(); this.isUpdateMethod = method.getMappingTargetParameter() != null; this.definingType = method.getDefiningType(); + this.isStatic = method.isStatic(); + this.name = method.getName(); } private MethodReference(BuiltInMethod method, ConversionContext contextParam) { - super( method ); + this.sourceParameters = Parameter.getSourceParameters( method.getParameters() ); + this.returnType = method.getReturnType(); this.declaringMapper = null; this.providingParameter = null; this.contextParam = method.getContextParameter( contextParam ); @@ -105,6 +114,8 @@ public class MethodReference extends MappingMethod implements Assignment { this.definingType = null; this.isUpdateMethod = method.getMappingTargetParameter() != null; this.parameterBindings = ParameterBinding.fromParameters( method.getParameters() ); + this.isStatic = method.isStatic(); + this.name = method.getName(); } public MapperReference getDeclaringMapper() { @@ -127,6 +138,14 @@ public class MethodReference extends MappingMethod implements Assignment { return assignment; } + public String getName() { + return name; + } + + public List getSourceParameters() { + return sourceParameters; + } + @Override public void setAssignment( Assignment assignment ) { this.assignment = assignment; @@ -225,11 +244,20 @@ public class MethodReference extends MappingMethod implements Assignment { } } + @Override + public Type getReturnType() { + return returnType; + } + @Override public boolean isCallingUpdateMethod() { return isUpdateMethod; } + public boolean isStatic() { + return isStatic; + } + public List getParameterBindings() { return parameterBindings; }