mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#302 Renaming MappingContext -> MappingBuilderContext
This commit is contained in:
parent
a5dc5d78ab
commit
6e24db8196
@ -56,7 +56,7 @@ public class AssignmentFactory {
|
|||||||
return new Direct( sourceRef );
|
return new Direct( sourceRef );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FactoryMethod createFactoryMethod( Type returnType, MappingContext ctx ) {
|
public static FactoryMethod createFactoryMethod( Type returnType, MappingBuilderContext ctx ) {
|
||||||
FactoryMethod result = null;
|
FactoryMethod result = null;
|
||||||
for ( SourceMethod method : ctx.getSourceModel() ) {
|
for ( SourceMethod method : ctx.getSourceModel() ) {
|
||||||
if ( !method.overridesMethod() && !method.isIterableMapping() && !method.isMapMapping()
|
if ( !method.overridesMethod() && !method.isIterableMapping() && !method.isMapMapping()
|
||||||
|
@ -56,10 +56,10 @@ public class BeanMappingMethod extends MappingMethod {
|
|||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
private SourceMethod method;
|
private SourceMethod method;
|
||||||
|
|
||||||
public Builder mappingContext(MappingContext mappingContext) {
|
public Builder mappingContext(MappingBuilderContext mappingContext) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -44,9 +44,9 @@ public class EnumMappingMethod extends MappingMethod {
|
|||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private SourceMethod method;
|
private SourceMethod method;
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
|
|
||||||
public Builder mappingContext( MappingContext mappingContext ) {
|
public Builder mappingContext( MappingBuilderContext mappingContext ) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@ public class IterableMappingMethod extends MappingMethod {
|
|||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
|
||||||
private Method method;
|
private Method method;
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
private String dateFormat;
|
private String dateFormat;
|
||||||
private List<TypeMirror> qualifiers;
|
private List<TypeMirror> qualifiers;
|
||||||
|
|
||||||
public Builder mappingContext(MappingContext mappingContext) {
|
public Builder mappingContext(MappingBuilderContext mappingContext) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ public class MapMappingMethod extends MappingMethod {
|
|||||||
private List<TypeMirror> keyQualifiers;
|
private List<TypeMirror> keyQualifiers;
|
||||||
private List<TypeMirror> valueQualifiers;
|
private List<TypeMirror> valueQualifiers;
|
||||||
private Method method;
|
private Method method;
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
|
|
||||||
public Builder mappingContext(MappingContext mappingContext) {
|
public Builder mappingContext(MappingBuilderContext mappingContext) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package org.mapstruct.ap.model;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.processing.Messager;
|
import javax.annotation.processing.Messager;
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
@ -38,7 +39,7 @@ import org.mapstruct.ap.option.Options;
|
|||||||
* This class provides the context for the builders.
|
* This class provides the context for the builders.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* The following mappers make use of this context:
|
* The following builders make use of this context:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@link BeanMappingMethod.Builder}</li>
|
* <li>{@link BeanMappingMethod.Builder}</li>
|
||||||
* <li>{@link PropertyMappingMethod.Builder}</li>
|
* <li>{@link PropertyMappingMethod.Builder}</li>
|
||||||
@ -59,7 +60,7 @@ import org.mapstruct.ap.option.Options;
|
|||||||
*
|
*
|
||||||
* @author Sjaak Derksen
|
* @author Sjaak Derksen
|
||||||
*/
|
*/
|
||||||
public class MappingContext {
|
public class MappingBuilderContext {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves the most suitable way for mapping an element (property, iterable element etc.) from source to target.
|
* Resolves the most suitable way for mapping an element (property, iterable element etc.) from source to target.
|
||||||
@ -119,7 +120,7 @@ public class MappingContext {
|
|||||||
private final MappingResolver mappingResolver;
|
private final MappingResolver mappingResolver;
|
||||||
private final List<MappingMethod> mappingsToGenerate = new ArrayList<MappingMethod>();
|
private final List<MappingMethod> mappingsToGenerate = new ArrayList<MappingMethod>();
|
||||||
|
|
||||||
public MappingContext(TypeFactory typeFactory,
|
public MappingBuilderContext(TypeFactory typeFactory,
|
||||||
Elements elementUtils,
|
Elements elementUtils,
|
||||||
Types typeUtils,
|
Types typeUtils,
|
||||||
Messager messager,
|
Messager messager,
|
@ -63,13 +63,13 @@ public class PropertyMapping extends ModelElement {
|
|||||||
|
|
||||||
public static class PropertyMappingBuilder {
|
public static class PropertyMappingBuilder {
|
||||||
|
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
private SourceMethod method;
|
private SourceMethod method;
|
||||||
private ExecutableElement targetAccessor;
|
private ExecutableElement targetAccessor;
|
||||||
private String targetPropertyName;
|
private String targetPropertyName;
|
||||||
private Parameter parameter;
|
private Parameter parameter;
|
||||||
|
|
||||||
public PropertyMappingBuilder mappingContext(MappingContext mappingContext) {
|
public PropertyMappingBuilder mappingContext(MappingBuilderContext mappingContext) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -321,14 +321,14 @@ public class PropertyMapping extends ModelElement {
|
|||||||
|
|
||||||
public static class ConstantMappingBuilder {
|
public static class ConstantMappingBuilder {
|
||||||
|
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
private SourceMethod method;
|
private SourceMethod method;
|
||||||
private String constantExpression;
|
private String constantExpression;
|
||||||
private ExecutableElement targetAccessor;
|
private ExecutableElement targetAccessor;
|
||||||
private String dateFormat;
|
private String dateFormat;
|
||||||
private List<TypeMirror> qualifiers;
|
private List<TypeMirror> qualifiers;
|
||||||
|
|
||||||
public ConstantMappingBuilder mappingContext(MappingContext mappingContext) {
|
public ConstantMappingBuilder mappingContext(MappingBuilderContext mappingContext) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -415,12 +415,12 @@ public class PropertyMapping extends ModelElement {
|
|||||||
|
|
||||||
public static class JavaExpressionMappingBuilder {
|
public static class JavaExpressionMappingBuilder {
|
||||||
|
|
||||||
private MappingContext ctx;
|
private MappingBuilderContext ctx;
|
||||||
private SourceMethod method;
|
private SourceMethod method;
|
||||||
private String javaExpression;
|
private String javaExpression;
|
||||||
private ExecutableElement targetAccessor;
|
private ExecutableElement targetAccessor;
|
||||||
|
|
||||||
public JavaExpressionMappingBuilder mappingContext(MappingContext mappingContext) {
|
public JavaExpressionMappingBuilder mappingContext(MappingBuilderContext mappingContext) {
|
||||||
this.ctx = mappingContext;
|
this.ctx = mappingContext;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ import org.mapstruct.ap.model.IterableMappingMethod;
|
|||||||
import org.mapstruct.ap.model.MapMappingMethod;
|
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.MappingContext;
|
import org.mapstruct.ap.model.MappingBuilderContext;
|
||||||
import org.mapstruct.ap.model.MappingMethod;
|
import org.mapstruct.ap.model.MappingMethod;
|
||||||
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;
|
||||||
@ -69,7 +69,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
private Messager messager;
|
private Messager messager;
|
||||||
private Options options;
|
private Options options;
|
||||||
private TypeFactory typeFactory;
|
private TypeFactory typeFactory;
|
||||||
private MappingContext mappingContext;
|
private MappingBuilderContext mappingContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, List<SourceMethod> sourceModel) {
|
public Mapper process(ProcessorContext context, TypeElement mapperTypeElement, List<SourceMethod> sourceModel) {
|
||||||
@ -81,7 +81,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
|||||||
|
|
||||||
List<MapperReference> mapperReferences = initReferencedMappers( mapperTypeElement );
|
List<MapperReference> mapperReferences = initReferencedMappers( mapperTypeElement );
|
||||||
|
|
||||||
MappingContext ctx = new MappingContext(
|
MappingBuilderContext ctx = new MappingBuilderContext(
|
||||||
typeFactory,
|
typeFactory,
|
||||||
elementUtils,
|
elementUtils,
|
||||||
typeUtils,
|
typeUtils,
|
||||||
|
@ -33,7 +33,7 @@ import org.mapstruct.ap.conversion.Conversions;
|
|||||||
import org.mapstruct.ap.model.AssignmentFactory;
|
import org.mapstruct.ap.model.AssignmentFactory;
|
||||||
import org.mapstruct.ap.model.Direct;
|
import org.mapstruct.ap.model.Direct;
|
||||||
import org.mapstruct.ap.model.MapperReference;
|
import org.mapstruct.ap.model.MapperReference;
|
||||||
import org.mapstruct.ap.model.MappingContext.MappingResolver;
|
import org.mapstruct.ap.model.MappingBuilderContext.MappingResolver;
|
||||||
import org.mapstruct.ap.model.VirtualMappingMethod;
|
import org.mapstruct.ap.model.VirtualMappingMethod;
|
||||||
import org.mapstruct.ap.model.assignment.Assignment;
|
import org.mapstruct.ap.model.assignment.Assignment;
|
||||||
import org.mapstruct.ap.model.common.ConversionContext;
|
import org.mapstruct.ap.model.common.ConversionContext;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user