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,
|
* 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>
|
||||||
|
@ -23,8 +23,8 @@ import java.lang.annotation.Target;
|
|||||||
* @Mapper
|
* @Mapper
|
||||||
* public interface MyMapper {
|
* public interface MyMapper {
|
||||||
* @Mappings({
|
* @Mappings({
|
||||||
* @Mapping(source = "first", target = "firstProperty"),
|
* @Mapping(target = "firstProperty", source = "first"),
|
||||||
* @Mapping(source = "second", target = "secondProperty")
|
* @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
|
||||||
* @Mapper
|
* @Mapper
|
||||||
* public interface MyMapper {
|
* public interface MyMapper {
|
||||||
* @Mapping(source = "first", target = "firstProperty"),
|
* @Mapping(target = "firstProperty", source = "first"),
|
||||||
* @Mapping(source = "second", target = "secondProperty")
|
* @Mapping(target = "secondProperty", source = "second")
|
||||||
* HumanDto toHumanDto(Human human);
|
* HumanDto toHumanDto(Human human);
|
||||||
* }
|
* }
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
|
@ -27,9 +27,9 @@ import java.lang.annotation.Target;
|
|||||||
*
|
*
|
||||||
* public enum ExternalOrderType { RETAIL, B2B, SPECIAL, DEFAULT }
|
* public enum ExternalOrderType { RETAIL, B2B, SPECIAL, DEFAULT }
|
||||||
*
|
*
|
||||||
* @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);
|
||||||
* </code>
|
* </code>
|
||||||
* Mapping result:
|
* Mapping result:
|
||||||
|
@ -22,8 +22,8 @@ import java.lang.annotation.Target;
|
|||||||
* @Mapper
|
* @Mapper
|
||||||
* public interface GenderMapper {
|
* public interface GenderMapper {
|
||||||
* @ValueMappings({
|
* @ValueMappings({
|
||||||
* @ValueMapping(source = "MALE", target = "M"),
|
* @ValueMapping(target = "M", source = "MALE"),
|
||||||
* @ValueMapping(source = "FEMALE", target = "F")
|
* @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
|
||||||
* @Mapper
|
* @Mapper
|
||||||
* public interface GenderMapper {
|
* public interface GenderMapper {
|
||||||
* @ValueMapping(source = "MALE", target = "M"),
|
* @ValueMapping(target = "M", source = "MALE"),
|
||||||
* @ValueMapping(source = "FEMALE", target = "F")
|
* @ValueMapping(target = "F", source = "FEMALE")
|
||||||
* GenderDto mapToDto(Gender gender);
|
* GenderDto mapToDto(Gender gender);
|
||||||
* }
|
* }
|
||||||
* </code></pre>
|
* </code></pre>
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ import static org.mapstruct.ap.internal.util.Collections.last;
|
|||||||
* mapping method:
|
* mapping method:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Mapping(source = "in.propA.propB" target = "propC")
|
* @Mapping(target = "propC", source = "in.propA.propB")
|
||||||
* TypeB mappingMethod(TypeA in);
|
* TypeB mappingMethod(TypeA in);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -32,7 +32,7 @@ import static org.mapstruct.ap.internal.util.Collections.first;
|
|||||||
* method:
|
* method:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* @Mapping(source = "in.propA.propB" target = "propC")
|
* @Mapping(target = "propC", source = "in.propA.propB")
|
||||||
* TypeB mappingMethod(TypeA in);
|
* TypeB mappingMethod(TypeA in);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
x
Reference in New Issue
Block a user