#2368 fix order of target parameter in documentation

This commit is contained in:
Jeroen van Wilgenburg 2021-03-01 07:27:47 +01:00 committed by Filip Hrisafov
parent 85af901ea7
commit d5703d3ee8
10 changed files with 27 additions and 27 deletions

View File

@ -47,7 +47,7 @@ import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
* uses = MarkMapper.class, * uses = MarkMapper.class,
* injectionStrategy = InjectionStrategy.CONSTRUCTOR) * injectionStrategy = InjectionStrategy.CONSTRUCTOR)
* public interface CarMapper { * public interface CarMapper {
* @Mapping(source = "mark", target = "name") * @Mapping(target = "name", source = "mark")
* CarDto convertMap(CarEntity carEntity); * CarDto convertMap(CarEntity carEntity);
* } * }
* </code></pre> * </code></pre>

View File

@ -23,8 +23,8 @@ import java.lang.annotation.Target;
* &#64;Mapper * &#64;Mapper
* public interface MyMapper { * public interface MyMapper {
* &#64;Mappings({ * &#64;Mappings({
* &#64;Mapping(source = "first", target = "firstProperty"), * &#64;Mapping(target = "firstProperty", source = "first"),
* &#64;Mapping(source = "second", target = "secondProperty") * &#64;Mapping(target = "secondProperty", source = "second")
* }) * })
* HumanDto toHumanDto(Human human); * HumanDto toHumanDto(Human human);
* } * }
@ -33,8 +33,8 @@ import java.lang.annotation.Target;
* // Java 8 and later * // Java 8 and later
* &#64;Mapper * &#64;Mapper
* public interface MyMapper { * public interface MyMapper {
* &#64;Mapping(source = "first", target = "firstProperty"), * &#64;Mapping(target = "firstProperty", source = "first"),
* &#64;Mapping(source = "second", target = "secondProperty") * &#64;Mapping(target = "secondProperty", source = "second")
* HumanDto toHumanDto(Human human); * HumanDto toHumanDto(Human human);
* } * }
* </code></pre> * </code></pre>

View File

@ -27,9 +27,9 @@ import java.lang.annotation.Target;
* *
* public enum ExternalOrderType { RETAIL, B2B, SPECIAL, DEFAULT } * public enum ExternalOrderType { RETAIL, B2B, SPECIAL, DEFAULT }
* *
* &#64;ValueMapping(source = "EXTRA", target = "SPECIAL"), * &#64;ValueMapping(target = "SPECIAL", source = "EXTRA"),
* &#64;ValueMapping(source = "STANDARD", target = "DEFAULT"), * &#64;ValueMapping(target = "DEFAULT", source = "STANDARD"),
* &#64;ValueMapping(source = "NORMAL", target = "DEFAULT") * &#64;ValueMapping(target = "DEFAULT", source = "NORMAL")
* ExternalOrderType orderTypeToExternalOrderType(OrderType orderType); * ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
* </code> * </code>
* Mapping result: * Mapping result:

View File

@ -22,8 +22,8 @@ import java.lang.annotation.Target;
* &#64;Mapper * &#64;Mapper
* public interface GenderMapper { * public interface GenderMapper {
* &#64;ValueMappings({ * &#64;ValueMappings({
* &#64;ValueMapping(source = "MALE", target = "M"), * &#64;ValueMapping(target = "M", source = "MALE"),
* &#64;ValueMapping(source = "FEMALE", target = "F") * &#64;ValueMapping(target = "F", source = "FEMALE")
* }) * })
* GenderDto mapToDto(Gender gender); * GenderDto mapToDto(Gender gender);
* } * }
@ -32,8 +32,8 @@ import java.lang.annotation.Target;
* //Java 8 and later * //Java 8 and later
* &#64;Mapper * &#64;Mapper
* public interface GenderMapper { * public interface GenderMapper {
* &#64;ValueMapping(source = "MALE", target = "M"), * &#64;ValueMapping(target = "M", source = "MALE"),
* &#64;ValueMapping(source = "FEMALE", target = "F") * &#64;ValueMapping(target = "F", source = "FEMALE")
* GenderDto mapToDto(Gender gender); * GenderDto mapToDto(Gender gender);
* } * }
* </code></pre> * </code></pre>

View File

@ -54,7 +54,7 @@ Use the annotation `@InheritInverseConfiguration` to indicate that a method shal
@Mapper @Mapper
public interface CarMapper { public interface CarMapper {
@Mapping(source = "numberOfSeats", target = "seatCount") @Mapping(target = "seatCount", source = "numberOfSeats")
CarDto carToDto(Car car); CarDto carToDto(Car car);
@InheritInverseConfiguration @InheritInverseConfiguration

View File

@ -16,11 +16,11 @@ To create a mapper simply define a Java interface with the required mapping meth
@Mapper @Mapper
public interface CarMapper { public interface CarMapper {
@Mapping(source = "make", target = "manufacturer") @Mapping(target = "manufacturer", source = "make")
@Mapping(source = "numberOfSeats", target = "seatCount") @Mapping(target = "seatCount", source = "numberOfSeats")
CarDto carToCarDto(Car car); CarDto carToCarDto(Car car);
@Mapping(source = "name", target = "fullName") @Mapping(target = "fullName", source = "name")
PersonDto personToPersonDto(Person person); PersonDto personToPersonDto(Person person);
} }
---- ----
@ -236,8 +236,8 @@ MapStruct also supports mapping methods with several source parameters. This is
@Mapper @Mapper
public interface AddressMapper { public interface AddressMapper {
@Mapping(source = "person.description", target = "description") @Mapping(target = "description", source = "person.description")
@Mapping(source = "address.houseNo", target = "houseNumber") @Mapping(target = "houseNumber", source = "address.houseNo")
DeliveryAddressDto personAndAddressToDeliveryAddressDto(Person person, Address address); DeliveryAddressDto personAndAddressToDeliveryAddressDto(Person person, Address address);
} }
---- ----
@ -267,8 +267,8 @@ MapStruct also offers the possibility to directly refer to a source parameter.
@Mapper @Mapper
public interface AddressMapper { public interface AddressMapper {
@Mapping(source = "person.description", target = "description") @Mapping(target = "description", source = "person.description")
@Mapping(source = "hn", target = "houseNumber") @Mapping(target = "houseNumber", source = "hn")
DeliveryAddressDto personAndAddressToDeliveryAddressDto(Person person, Integer hn); DeliveryAddressDto personAndAddressToDeliveryAddressDto(Person person, Integer hn);
} }
---- ----
@ -368,7 +368,7 @@ public interface CustomerMapper {
CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class ); CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class );
@Mapping(source = "customerName", target = "name") @Mapping(target = "name", source = "customerName")
Customer toCustomer(CustomerDto customerDto); Customer toCustomer(CustomerDto customerDto);
@InheritInverseConfiguration @InheritInverseConfiguration

View File

@ -20,9 +20,9 @@ public interface OrderMapper {
OrderMapper INSTANCE = Mappers.getMapper( OrderMapper.class ); OrderMapper INSTANCE = Mappers.getMapper( OrderMapper.class );
@ValueMappings({ @ValueMappings({
@ValueMapping(source = "EXTRA", target = "SPECIAL"), @ValueMapping(target = "SPECIAL", source = "EXTRA"),
@ValueMapping(source = "STANDARD", target = "DEFAULT"), @ValueMapping(target = "DEFAULT", source = "STANDARD"),
@ValueMapping(source = "NORMAL", target = "DEFAULT") @ValueMapping(target = "DEFAULT", source = "NORMAL")
}) })
ExternalOrderType orderTypeToExternalOrderType(OrderType orderType); ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
} }

View File

@ -34,7 +34,7 @@ import static org.mapstruct.ap.internal.util.Collections.last;
* mapping method: * mapping method:
* *
* <pre> * <pre>
* &#64;Mapping(source = "in.propA.propB" target = "propC") * &#64;Mapping(target = "propC", source = "in.propA.propB")
* TypeB mappingMethod(TypeA in); * TypeB mappingMethod(TypeA in);
* </pre> * </pre>
* *

View File

@ -32,7 +32,7 @@ import static org.mapstruct.ap.internal.util.Collections.first;
* method: * method:
* *
* <pre> * <pre>
* &#64;Mapping(source = "in.propA.propB" target = "propC") * &#64;Mapping(target = "propC", source = "in.propA.propB")
* TypeB mappingMethod(TypeA in); * TypeB mappingMethod(TypeA in);
* </pre> * </pre>
* *

View File

@ -42,7 +42,7 @@ public interface CarMapper {
CarMapper INSTANCE = Mappers.getMapper( CarMapper.class ); CarMapper INSTANCE = Mappers.getMapper( CarMapper.class );
@Mapping(source = "numberOfSeats", target = "seatCount") @Mapping(target = "seatCount", source = "numberOfSeats")
CarDto carToCarDto(Car car); CarDto carToCarDto(Car car);
} }
``` ```