mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2368 fix order of target parameter in documentation
This commit is contained in:
parent
85af901ea7
commit
d5703d3ee8
@ -47,7 +47,7 @@ import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
|
||||
* uses = MarkMapper.class,
|
||||
* injectionStrategy = InjectionStrategy.CONSTRUCTOR)
|
||||
* public interface CarMapper {
|
||||
* @Mapping(source = "mark", target = "name")
|
||||
* @Mapping(target = "name", source = "mark")
|
||||
* CarDto convertMap(CarEntity carEntity);
|
||||
* }
|
||||
* </code></pre>
|
||||
|
@ -23,8 +23,8 @@ import java.lang.annotation.Target;
|
||||
* @Mapper
|
||||
* public interface MyMapper {
|
||||
* @Mappings({
|
||||
* @Mapping(source = "first", target = "firstProperty"),
|
||||
* @Mapping(source = "second", target = "secondProperty")
|
||||
* @Mapping(target = "firstProperty", source = "first"),
|
||||
* @Mapping(target = "secondProperty", source = "second")
|
||||
* })
|
||||
* HumanDto toHumanDto(Human human);
|
||||
* }
|
||||
@ -33,8 +33,8 @@ import java.lang.annotation.Target;
|
||||
* // Java 8 and later
|
||||
* @Mapper
|
||||
* public interface MyMapper {
|
||||
* @Mapping(source = "first", target = "firstProperty"),
|
||||
* @Mapping(source = "second", target = "secondProperty")
|
||||
* @Mapping(target = "firstProperty", source = "first"),
|
||||
* @Mapping(target = "secondProperty", source = "second")
|
||||
* HumanDto toHumanDto(Human human);
|
||||
* }
|
||||
* </code></pre>
|
||||
|
@ -27,9 +27,9 @@ import java.lang.annotation.Target;
|
||||
*
|
||||
* public enum ExternalOrderType { RETAIL, B2B, SPECIAL, DEFAULT }
|
||||
*
|
||||
* @ValueMapping(source = "EXTRA", target = "SPECIAL"),
|
||||
* @ValueMapping(source = "STANDARD", target = "DEFAULT"),
|
||||
* @ValueMapping(source = "NORMAL", target = "DEFAULT")
|
||||
* @ValueMapping(target = "SPECIAL", source = "EXTRA"),
|
||||
* @ValueMapping(target = "DEFAULT", source = "STANDARD"),
|
||||
* @ValueMapping(target = "DEFAULT", source = "NORMAL")
|
||||
* ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
|
||||
* </code>
|
||||
* Mapping result:
|
||||
|
@ -22,8 +22,8 @@ import java.lang.annotation.Target;
|
||||
* @Mapper
|
||||
* public interface GenderMapper {
|
||||
* @ValueMappings({
|
||||
* @ValueMapping(source = "MALE", target = "M"),
|
||||
* @ValueMapping(source = "FEMALE", target = "F")
|
||||
* @ValueMapping(target = "M", source = "MALE"),
|
||||
* @ValueMapping(target = "F", source = "FEMALE")
|
||||
* })
|
||||
* GenderDto mapToDto(Gender gender);
|
||||
* }
|
||||
@ -32,8 +32,8 @@ import java.lang.annotation.Target;
|
||||
* //Java 8 and later
|
||||
* @Mapper
|
||||
* public interface GenderMapper {
|
||||
* @ValueMapping(source = "MALE", target = "M"),
|
||||
* @ValueMapping(source = "FEMALE", target = "F")
|
||||
* @ValueMapping(target = "M", source = "MALE"),
|
||||
* @ValueMapping(target = "F", source = "FEMALE")
|
||||
* GenderDto mapToDto(Gender gender);
|
||||
* }
|
||||
* </code></pre>
|
||||
|
@ -54,7 +54,7 @@ Use the annotation `@InheritInverseConfiguration` to indicate that a method shal
|
||||
@Mapper
|
||||
public interface CarMapper {
|
||||
|
||||
@Mapping(source = "numberOfSeats", target = "seatCount")
|
||||
@Mapping(target = "seatCount", source = "numberOfSeats")
|
||||
CarDto carToDto(Car car);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
|
@ -16,11 +16,11 @@ To create a mapper simply define a Java interface with the required mapping meth
|
||||
@Mapper
|
||||
public interface CarMapper {
|
||||
|
||||
@Mapping(source = "make", target = "manufacturer")
|
||||
@Mapping(source = "numberOfSeats", target = "seatCount")
|
||||
@Mapping(target = "manufacturer", source = "make")
|
||||
@Mapping(target = "seatCount", source = "numberOfSeats")
|
||||
CarDto carToCarDto(Car car);
|
||||
|
||||
@Mapping(source = "name", target = "fullName")
|
||||
@Mapping(target = "fullName", source = "name")
|
||||
PersonDto personToPersonDto(Person person);
|
||||
}
|
||||
----
|
||||
@ -236,8 +236,8 @@ MapStruct also supports mapping methods with several source parameters. This is
|
||||
@Mapper
|
||||
public interface AddressMapper {
|
||||
|
||||
@Mapping(source = "person.description", target = "description")
|
||||
@Mapping(source = "address.houseNo", target = "houseNumber")
|
||||
@Mapping(target = "description", source = "person.description")
|
||||
@Mapping(target = "houseNumber", source = "address.houseNo")
|
||||
DeliveryAddressDto personAndAddressToDeliveryAddressDto(Person person, Address address);
|
||||
}
|
||||
----
|
||||
@ -267,8 +267,8 @@ MapStruct also offers the possibility to directly refer to a source parameter.
|
||||
@Mapper
|
||||
public interface AddressMapper {
|
||||
|
||||
@Mapping(source = "person.description", target = "description")
|
||||
@Mapping(source = "hn", target = "houseNumber")
|
||||
@Mapping(target = "description", source = "person.description")
|
||||
@Mapping(target = "houseNumber", source = "hn")
|
||||
DeliveryAddressDto personAndAddressToDeliveryAddressDto(Person person, Integer hn);
|
||||
}
|
||||
----
|
||||
@ -368,7 +368,7 @@ public interface CustomerMapper {
|
||||
|
||||
CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class );
|
||||
|
||||
@Mapping(source = "customerName", target = "name")
|
||||
@Mapping(target = "name", source = "customerName")
|
||||
Customer toCustomer(CustomerDto customerDto);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
|
@ -20,9 +20,9 @@ public interface OrderMapper {
|
||||
OrderMapper INSTANCE = Mappers.getMapper( OrderMapper.class );
|
||||
|
||||
@ValueMappings({
|
||||
@ValueMapping(source = "EXTRA", target = "SPECIAL"),
|
||||
@ValueMapping(source = "STANDARD", target = "DEFAULT"),
|
||||
@ValueMapping(source = "NORMAL", target = "DEFAULT")
|
||||
@ValueMapping(target = "SPECIAL", source = "EXTRA"),
|
||||
@ValueMapping(target = "DEFAULT", source = "STANDARD"),
|
||||
@ValueMapping(target = "DEFAULT", source = "NORMAL")
|
||||
})
|
||||
ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import static org.mapstruct.ap.internal.util.Collections.last;
|
||||
* mapping method:
|
||||
*
|
||||
* <pre>
|
||||
* @Mapping(source = "in.propA.propB" target = "propC")
|
||||
* @Mapping(target = "propC", source = "in.propA.propB")
|
||||
* TypeB mappingMethod(TypeA in);
|
||||
* </pre>
|
||||
*
|
||||
|
@ -32,7 +32,7 @@ import static org.mapstruct.ap.internal.util.Collections.first;
|
||||
* method:
|
||||
*
|
||||
* <pre>
|
||||
* @Mapping(source = "in.propA.propB" target = "propC")
|
||||
* @Mapping(target = "propC", source = "in.propA.propB")
|
||||
* TypeB mappingMethod(TypeA in);
|
||||
* </pre>
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user