mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#81, refactoring MappingMethodReference to MethodReference to accomodate for factory usage of this method
This commit is contained in:
parent
b456cc8b6b
commit
a9d2f788de
@ -34,10 +34,10 @@ import org.mapstruct.ap.util.Strings;
|
|||||||
*/
|
*/
|
||||||
public class IterableMappingMethod extends MappingMethod {
|
public class IterableMappingMethod extends MappingMethod {
|
||||||
|
|
||||||
private final MappingMethodReference elementMappingMethod;
|
private final MethodReference elementMappingMethod;
|
||||||
private final TypeConversion conversion;
|
private final TypeConversion conversion;
|
||||||
|
|
||||||
public IterableMappingMethod(Method method, MappingMethodReference elementMappingMethod,
|
public IterableMappingMethod(Method method, MethodReference elementMappingMethod,
|
||||||
TypeConversion conversion) {
|
TypeConversion conversion) {
|
||||||
super( method );
|
super( method );
|
||||||
this.elementMappingMethod = elementMappingMethod;
|
this.elementMappingMethod = elementMappingMethod;
|
||||||
@ -54,7 +54,7 @@ public class IterableMappingMethod extends MappingMethod {
|
|||||||
throw new IllegalStateException( "Method " + this + " has no source parameter." );
|
throw new IllegalStateException( "Method " + this + " has no source parameter." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappingMethodReference getElementMappingMethod() {
|
public MethodReference getElementMappingMethod() {
|
||||||
return elementMappingMethod;
|
return elementMappingMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,13 +33,13 @@ import org.mapstruct.ap.util.Strings;
|
|||||||
*/
|
*/
|
||||||
public class MapMappingMethod extends MappingMethod {
|
public class MapMappingMethod extends MappingMethod {
|
||||||
|
|
||||||
private final MappingMethodReference keyMappingMethod;
|
private final MethodReference keyMappingMethod;
|
||||||
private final MappingMethodReference valueMappingMethod;
|
private final MethodReference valueMappingMethod;
|
||||||
private final TypeConversion keyConversion;
|
private final TypeConversion keyConversion;
|
||||||
private final TypeConversion valueConversion;
|
private final TypeConversion valueConversion;
|
||||||
|
|
||||||
public MapMappingMethod(Method method, MappingMethodReference keyMappingMethod, TypeConversion keyConversion,
|
public MapMappingMethod(Method method, MethodReference keyMappingMethod, TypeConversion keyConversion,
|
||||||
MappingMethodReference valueMappingMethod, TypeConversion valueConversion) {
|
MethodReference valueMappingMethod, TypeConversion valueConversion) {
|
||||||
super( method );
|
super( method );
|
||||||
|
|
||||||
this.keyMappingMethod = keyMappingMethod;
|
this.keyMappingMethod = keyMappingMethod;
|
||||||
@ -58,7 +58,7 @@ public class MapMappingMethod extends MappingMethod {
|
|||||||
throw new IllegalStateException( "Method " + this + " has no source parameter." );
|
throw new IllegalStateException( "Method " + this + " has no source parameter." );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappingMethodReference getKeyMappingMethod() {
|
public MethodReference getKeyMappingMethod() {
|
||||||
return keyMappingMethod;
|
return keyMappingMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class MapMappingMethod extends MappingMethod {
|
|||||||
return keyConversion;
|
return keyConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappingMethodReference getValueMappingMethod() {
|
public MethodReference getValueMappingMethod() {
|
||||||
return valueMappingMethod;
|
return valueMappingMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,11 +29,11 @@ import org.mapstruct.ap.model.source.Method;
|
|||||||
*
|
*
|
||||||
* @author Gunnar Morling
|
* @author Gunnar Morling
|
||||||
*/
|
*/
|
||||||
public class MappingMethodReference extends MappingMethod {
|
public class MethodReference extends MappingMethod {
|
||||||
|
|
||||||
private final MapperReference declaringMapper;
|
private final MapperReference declaringMapper;
|
||||||
|
|
||||||
public MappingMethodReference(Method method, MapperReference declaringMapper) {
|
public MethodReference(Method method, MapperReference declaringMapper) {
|
||||||
super( method );
|
super( method );
|
||||||
this.declaringMapper = declaringMapper;
|
this.declaringMapper = declaringMapper;
|
||||||
}
|
}
|
@ -44,12 +44,12 @@ public class PropertyMapping extends ModelElement {
|
|||||||
private final Type targetType;
|
private final Type targetType;
|
||||||
private final boolean isTargetAccessorSetter;
|
private final boolean isTargetAccessorSetter;
|
||||||
|
|
||||||
private final MappingMethodReference mappingMethod;
|
private final MethodReference mappingMethod;
|
||||||
private final TypeConversion conversion;
|
private final TypeConversion conversion;
|
||||||
|
|
||||||
public PropertyMapping(String sourceBeanName, String sourceName, String sourceAccessorName, Type sourceType,
|
public PropertyMapping(String sourceBeanName, String sourceName, String sourceAccessorName, Type sourceType,
|
||||||
String targetName, String targetAccessorName, Type targetType,
|
String targetName, String targetAccessorName, Type targetType,
|
||||||
MappingMethodReference mappingMethod, TypeConversion conversion) {
|
MethodReference mappingMethod, TypeConversion conversion) {
|
||||||
|
|
||||||
this.sourceBeanName = sourceBeanName;
|
this.sourceBeanName = sourceBeanName;
|
||||||
this.sourceName = sourceName;
|
this.sourceName = sourceName;
|
||||||
@ -93,7 +93,7 @@ public class PropertyMapping extends ModelElement {
|
|||||||
return targetType;
|
return targetType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MappingMethodReference getMappingMethod() {
|
public MethodReference getMappingMethod() {
|
||||||
return mappingMethod;
|
return mappingMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ import org.mapstruct.ap.model.MapMappingMethod;
|
|||||||
import org.mapstruct.ap.model.Mapper;
|
import org.mapstruct.ap.model.Mapper;
|
||||||
import org.mapstruct.ap.model.MapperReference;
|
import org.mapstruct.ap.model.MapperReference;
|
||||||
import org.mapstruct.ap.model.MappingMethod;
|
import org.mapstruct.ap.model.MappingMethod;
|
||||||
import org.mapstruct.ap.model.MappingMethodReference;
|
import org.mapstruct.ap.model.MethodReference;
|
||||||
import org.mapstruct.ap.model.PropertyMapping;
|
import org.mapstruct.ap.model.PropertyMapping;
|
||||||
import org.mapstruct.ap.model.TypeConversion;
|
import org.mapstruct.ap.model.TypeConversion;
|
||||||
import org.mapstruct.ap.model.common.Parameter;
|
import org.mapstruct.ap.model.common.Parameter;
|
||||||
@ -545,7 +545,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
|
|||||||
targetType = typeFactory.getReturnType( targetAcessor );
|
targetType = typeFactory.getReturnType( targetAcessor );
|
||||||
}
|
}
|
||||||
|
|
||||||
MappingMethodReference propertyMappingMethod = getMappingMethodReference(
|
MethodReference propertyMappingMethod = getMappingMethodReference(
|
||||||
mapperReferences,
|
mapperReferences,
|
||||||
methods,
|
methods,
|
||||||
sourceType,
|
sourceType,
|
||||||
@ -593,7 +593,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
MappingMethodReference elementMappingMethod =
|
MethodReference elementMappingMethod =
|
||||||
getMappingMethodReference( mapperReferences, methods, sourceElementType, targetElementType );
|
getMappingMethodReference( mapperReferences, methods, sourceElementType, targetElementType );
|
||||||
|
|
||||||
if ( !sourceElementType.isAssignableTo( targetElementType ) && conversion == null &&
|
if ( !sourceElementType.isAssignableTo( targetElementType ) && conversion == null &&
|
||||||
@ -637,13 +637,13 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
|
|||||||
"entry.getValue()"
|
"entry.getValue()"
|
||||||
);
|
);
|
||||||
|
|
||||||
MappingMethodReference keyMappingMethod = getMappingMethodReference(
|
MethodReference keyMappingMethod = getMappingMethodReference(
|
||||||
mapperReferences,
|
mapperReferences,
|
||||||
methods,
|
methods,
|
||||||
sourceKeyType,
|
sourceKeyType,
|
||||||
targetKeyType
|
targetKeyType
|
||||||
);
|
);
|
||||||
MappingMethodReference valueMappingMethod = getMappingMethodReference(
|
MethodReference valueMappingMethod = getMappingMethodReference(
|
||||||
mapperReferences,
|
mapperReferences,
|
||||||
methods,
|
methods,
|
||||||
sourceValueType,
|
sourceValueType,
|
||||||
@ -691,7 +691,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MappingMethodReference getMappingMethodReference(List<MapperReference> mapperReferences,
|
private MethodReference getMappingMethodReference(List<MapperReference> mapperReferences,
|
||||||
Iterable<Method> methods, Type parameterType,
|
Iterable<Method> methods, Type parameterType,
|
||||||
Type returnType) {
|
Type returnType) {
|
||||||
List<Method> candidatesWithMathingTargetType = new ArrayList<Method>();
|
List<Method> candidatesWithMathingTargetType = new ArrayList<Method>();
|
||||||
@ -751,7 +751,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Metho
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MappingMethodReference( method, mapperReference );
|
return new MethodReference( method, mapperReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
private int addToCandidateListIfMinimal(List<Method> candidatesWithBestMathingType, int bestMatchingTypeDistance,
|
private int addToCandidateListIfMinimal(List<Method> candidatesWithBestMathingType, int bestMatchingTypeDistance,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user