mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
Next version 1.6.0-SNAPSHOT
This commit is contained in:
parent
6ef64ea3aa
commit
6365a606c1
@ -1,89 +1,10 @@
|
||||
### Enhancements
|
||||
### Features
|
||||
|
||||
* Breaking change: (#3574) -
|
||||
This reverts #2560, because we've decided that `@BeanMapping(ignoreByDefault = true)` should only be applied to target properties and not to source properties.
|
||||
Source properties are ignored anyway, the `BeanMapping#unmappedSourcePolicy` should be used to control what should happen with unmapped source policy
|
||||
### Enhancements
|
||||
|
||||
### Bugs
|
||||
|
||||
* Breaking change: Presence check method used only once when multiple source parameters are provided (#3601)
|
||||
* Fix `@SubclassMapping` not working with `@BeanMapping#ignoreUnmappedSourceProperties` (#3609)
|
||||
* Fix duplicate method generation with recursive auto mapping (#3591)
|
||||
|
||||
### Documentation
|
||||
|
||||
* Fix documentation of `unmappedSourcePolicy` default value (#3635)
|
||||
* Fix documentation link of before and after mapping when using builders (#3639)
|
||||
* Fix typo in experimental note (#3634)
|
||||
* Add example classes for the passing target type documentation (#3504)
|
||||
|
||||
### Build
|
||||
|
||||
* Enforce whitespaces around the for colon with CheckStyle (#3642)
|
||||
|
||||
## Breaking changes
|
||||
|
||||
### Presence checks for source parameters
|
||||
|
||||
In 1.6, support for presence checks on source parameters has been added.
|
||||
This means that even if you want to map a source parameter directly to some target property the new `@SourceParameterCondition` or `@Condition(appliesTo = ConditionStrategy.SOURCE_PARAMETERS)` should be used.
|
||||
|
||||
e.g.
|
||||
|
||||
If we had the following in 1.5:
|
||||
```java
|
||||
@Mapper
|
||||
public interface OrderMapper {
|
||||
|
||||
@Mapping(source = "dto", target = "customer", conditionQualifiedByName = "mapCustomerFromOrder")
|
||||
Order map(OrderDTO dto);
|
||||
|
||||
@Condition
|
||||
@Named("mapCustomerFromOrder")
|
||||
default boolean mapCustomerFromOrder(OrderDTO dto) {
|
||||
return dto != null && dto.getCustomerName() != null;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
Then MapStruct would generate
|
||||
|
||||
```java
|
||||
public class OrderMapperImpl implements OrderMapper {
|
||||
|
||||
@Override
|
||||
public Order map(OrderDTO dto) {
|
||||
if ( dto == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Order order = new Order();
|
||||
|
||||
if ( mapCustomerFromOrder( dto ) ) {
|
||||
order.setCustomer( orderDtoToCustomer( orderDTO ) );
|
||||
}
|
||||
|
||||
return order;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In order for the same to be generated in 1.6, the mapper needs to look like this:
|
||||
|
||||
```java
|
||||
@Mapper
|
||||
public interface OrderMapper {
|
||||
|
||||
@Mapping(source = "dto", target = "customer", conditionQualifiedByName = "mapCustomerFromOrder")
|
||||
Order map(OrderDTO dto);
|
||||
|
||||
@SourceParameterCondition
|
||||
@Named("mapCustomerFromOrder")
|
||||
default boolean mapCustomerFromOrder(OrderDTO dto) {
|
||||
return dto != null && dto.getCustomerName() != null;
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>MapStruct Parent</name>
|
||||
@ -28,7 +28,7 @@
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<!-- value comes from property git.commit.author.time -->
|
||||
<project.build.outputTimestamp>2024-07-20T15:36:10Z</project.build.outputTimestamp>
|
||||
<project.build.outputTimestamp>${git.commit.author.time}</project.build.outputTimestamp>
|
||||
|
||||
<org.mapstruct.gem.version>1.0.0.Alpha3</org.mapstruct.gem.version>
|
||||
<org.apache.maven.plugins.enforcer.version>3.4.1</org.apache.maven.plugins.enforcer.version>
|
||||
|
2
pom.xml
2
pom.xml
@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<parent>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-parent</artifactId>
|
||||
<version>1.6.0.RC1</version>
|
||||
<version>1.6.0-SNAPSHOT</version>
|
||||
<relativePath>../parent/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user