mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#120 Renaming BasicMethod to Method
This commit is contained in:
parent
06b4220af8
commit
34484c6686
@ -27,7 +27,7 @@ import org.mapstruct.ap.model.common.Accessibility;
|
|||||||
import org.mapstruct.ap.model.common.ModelElement;
|
import org.mapstruct.ap.model.common.ModelElement;
|
||||||
import org.mapstruct.ap.model.common.Parameter;
|
import org.mapstruct.ap.model.common.Parameter;
|
||||||
import org.mapstruct.ap.model.common.Type;
|
import org.mapstruct.ap.model.common.Type;
|
||||||
import org.mapstruct.ap.model.source.BasicMethod;
|
import org.mapstruct.ap.model.source.Method;
|
||||||
import org.mapstruct.ap.util.Strings;
|
import org.mapstruct.ap.util.Strings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +43,7 @@ public abstract class MappingMethod extends ModelElement {
|
|||||||
private final Parameter targetParameter;
|
private final Parameter targetParameter;
|
||||||
private final Accessibility accessibility;
|
private final Accessibility accessibility;
|
||||||
|
|
||||||
protected MappingMethod(BasicMethod method) {
|
protected MappingMethod(Method method) {
|
||||||
this.name = method.getName();
|
this.name = method.getName();
|
||||||
this.parameters = method.getParameters();
|
this.parameters = method.getParameters();
|
||||||
this.returnType = method.getReturnType();
|
this.returnType = method.getReturnType();
|
||||||
|
@ -38,7 +38,7 @@ import org.mapstruct.ap.util.Strings;
|
|||||||
*
|
*
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public abstract class BuiltInMethod extends ModelElement implements BasicMethod {
|
public abstract class BuiltInMethod extends ModelElement implements Method {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +64,7 @@ public abstract class BuiltInMethod extends ModelElement implements BasicMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*
|
*
|
||||||
* Default the targetType should be assignable to the returnType and the sourceType to the parameter,
|
* Default the targetType should be assignable to the returnType and the sourceType to the parameter,
|
||||||
* excluding generic type variables. When the implementor sees a need for this, this method can be overridden.
|
* excluding generic type variables. When the implementor sees a need for this, this method can be overridden.
|
||||||
@ -79,7 +79,7 @@ public abstract class BuiltInMethod extends ModelElement implements BasicMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*
|
*
|
||||||
* @return all parameters are source parameters for build-in methods.
|
* @return all parameters are source parameters for build-in methods.
|
||||||
*/
|
*/
|
||||||
@ -89,7 +89,7 @@ public abstract class BuiltInMethod extends ModelElement implements BasicMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*
|
*
|
||||||
* declaring mapper is always null, being the MapperImpl itself. This method should not be overridden by
|
* declaring mapper is always null, being the MapperImpl itself. This method should not be overridden by
|
||||||
* implementors
|
* implementors
|
||||||
@ -101,7 +101,7 @@ public abstract class BuiltInMethod extends ModelElement implements BasicMethod
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Parameter> getParameters() {
|
public List<Parameter> getParameters() {
|
||||||
|
@ -31,7 +31,7 @@ import org.mapstruct.ap.model.common.Type;
|
|||||||
* There are 2 known implementors: {@link BuiltInMethod} and {@link Method}
|
* There are 2 known implementors: {@link BuiltInMethod} and {@link Method}
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public interface BasicMethod {
|
public interface Method {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the provided sourceType and provided targetType match with the parameter respectively
|
* Checks whether the provided sourceType and provided targetType match with the parameter respectively
|
@ -42,7 +42,7 @@ import org.mapstruct.ap.util.Strings;
|
|||||||
*
|
*
|
||||||
* @author Gunnar Morling
|
* @author Gunnar Morling
|
||||||
*/
|
*/
|
||||||
public class SourceMethod implements BasicMethod {
|
public class SourceMethod implements Method {
|
||||||
|
|
||||||
private final Type declaringMapper;
|
private final Type declaringMapper;
|
||||||
private final ExecutableElement executable;
|
private final ExecutableElement executable;
|
||||||
@ -143,7 +143,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Type getDeclaringMapper() {
|
public Type getDeclaringMapper() {
|
||||||
@ -155,7 +155,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -163,7 +163,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Parameter> getParameters() {
|
public List<Parameter> getParameters() {
|
||||||
@ -171,7 +171,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Parameter> getSourceParameters() {
|
public List<Parameter> getSourceParameters() {
|
||||||
@ -201,7 +201,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Type getReturnType() {
|
public Type getReturnType() {
|
||||||
@ -247,7 +247,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Parameter getTargetParameter() {
|
public Parameter getTargetParameter() {
|
||||||
@ -322,7 +322,7 @@ public class SourceMethod implements BasicMethod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc} {@link BasicMethod}
|
* {@inheritDoc} {@link Method}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean matches( Type sourceType, Type targetType ) {
|
public boolean matches( Type sourceType, Type targetType ) {
|
||||||
|
@ -56,7 +56,7 @@ import org.mapstruct.ap.model.TypeConversion;
|
|||||||
import org.mapstruct.ap.model.common.Parameter;
|
import org.mapstruct.ap.model.common.Parameter;
|
||||||
import org.mapstruct.ap.model.common.Type;
|
import org.mapstruct.ap.model.common.Type;
|
||||||
import org.mapstruct.ap.model.common.TypeFactory;
|
import org.mapstruct.ap.model.common.TypeFactory;
|
||||||
import org.mapstruct.ap.model.source.BasicMethod;
|
import org.mapstruct.ap.model.source.Method;
|
||||||
import org.mapstruct.ap.model.source.Mapping;
|
import org.mapstruct.ap.model.source.Mapping;
|
||||||
import org.mapstruct.ap.model.source.SourceMethod;
|
import org.mapstruct.ap.model.source.SourceMethod;
|
||||||
import org.mapstruct.ap.option.Options;
|
import org.mapstruct.ap.option.Options;
|
||||||
@ -760,7 +760,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private <T extends BasicMethod> T getBestMatch(SourceMethod mappingMethod, String mappedElement,
|
private <T extends Method> T getBestMatch(SourceMethod mappingMethod, String mappedElement,
|
||||||
Iterable<T> methods, Type parameterType,
|
Iterable<T> methods, Type parameterType,
|
||||||
Type returnType) {
|
Type returnType) {
|
||||||
List<T> candidatesWithMathingTargetType = new ArrayList<T>();
|
List<T> candidatesWithMathingTargetType = new ArrayList<T>();
|
||||||
@ -814,7 +814,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private <T extends BasicMethod> int addToCandidateListIfMinimal(List<T> candidatesWithBestMathingType,
|
private <T extends Method> int addToCandidateListIfMinimal(List<T> candidatesWithBestMathingType,
|
||||||
int bestMatchingTypeDistance, T method, int currentTypeDistance) {
|
int bestMatchingTypeDistance, T method, int currentTypeDistance) {
|
||||||
if ( currentTypeDistance == bestMatchingTypeDistance ) {
|
if ( currentTypeDistance == bestMatchingTypeDistance ) {
|
||||||
candidatesWithBestMathingType.add( method );
|
candidatesWithBestMathingType.add( method );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user