Skip to content

Commit 4d4385a

Browse files
committed
Blog post for 1.6.0.RC1
1 parent 7d14734 commit 4d4385a

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
title: "MapStruct 1.6.0.RC1 is out"
3+
author: Filip Hrisafov
4+
date: "2024-07-20"
5+
tags: [release, news]
6+
---
7+
8+
I am very happy to announce the first (and last) release candidate of MapStruct 1.6.
9+
We are looking into release the final version of 1.6 in the next two weeks.
10+
11+
This release provides mostly bug fixes since [1.6.0.Beta2](https://mapstruct.org/news/2024-04-20-mapstruct-1_6_0_Beta2-is-out/).
12+
13+
This release contains 2 breaking changes, have a look at them when upgrading
14+
15+
We'd like to thank our new supporters:
16+
17+
* [Lee Anne](https://github.com/AnneMayor)
18+
19+
And of course thanks to our previous supporters:
20+
21+
* [addesso SE](https://github.com/adessoSE)
22+
* [Bileto](https://opencollective.com/bileto)
23+
* [Cybozu](https://github.com/cybozu)
24+
* [Frederik Hahne](https://opencollective.com/atomfrede)
25+
* [Juyoung Kim](https://github.com/kjuyoung)
26+
* [Lansana](https://opencollective.com/lansana)
27+
* [Mariselvam](https://github.com/marisnb)
28+
* [PRISMA European Capacity Platform GmbH](https://github.com/jan-prisma)
29+
* [St. Galler Kantonalbank AG](https://opencollective.com/st-galler-kantonalbank-ag)
30+
31+
If you'd like to join this list and donate to the project MapStruct is accepting donations through [Open Collective](https://opencollective.com/mapstruct) or [GitHub](https://github.com/sponsors/mapstruct).
32+
33+
<!--more-->
34+
35+
Altogether, not less than [8 issues](https://github.com/mapstruct/mapstruct/issues?q=milestone%3A1.6.0.RC1) were fixed for this release.
36+
37+
This would not have been possible without our fantastic community of contributors:
38+
39+
* [@cmcgowanprovidertrust](https://github.com/cmcgowanprovidertrust)
40+
* [@hduelme](https://github.com/hduelme)
41+
* [@Hypnagokali](https://github.com/Hypnagokali)
42+
* [@Obolrom](https://github.com/Obolrom)
43+
44+
* and of course seasoned MapStruct hackers [Ben Zegveld](https://github.com/Zegveld), [Oliver Erhart](https://github.com/thunderhook), [Sjaak Derksen](https://github.com/sjaakd), [Filip Hrisafov](https://github.com/filiphr).
45+
46+
Thank you everyone for all your hard work!
47+
48+
Enough of the pep talk, let's take a closer look at the breaking changes:
49+
50+
### Revert `BeanMapping#ignoreByDefault` interaction with `unmappedSourcePolicy`
51+
52+
In 1.5.0 we started applying the `BeanMapping#ignoreByDefault` to source properties as well.
53+
However, we've decided that this was not the right approach, and we are reverting this change.
54+
The `BeanMapping#ignoreByDefault` should only be applied to target properties and not to source properties.
55+
Source properties are ignored anyway, the `BeanMapping#unmappedSourcePolicy` should be used to control what should happen with unmapped source policy.
56+
57+
### Presence checks for source parameters
58+
59+
In the 1.6 beta releases we added support for [presence checks on source parameters](2024-05-11-mapstruct-1_6_0_Beta2-is-out.md#conditional-mapping-for-source-parameters).
60+
61+
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.
62+
63+
e.g.
64+
65+
If we had the following in 1.5:
66+
{{< prettify java >}}
67+
@Mapper
68+
public interface OrderMapper {
69+
70+
@Mapping(source = "dto", target = "customer", conditionQualifiedByName = "mapCustomerFromOrder")
71+
Order map(OrderDTO dto);
72+
73+
@Condition
74+
@Named("mapCustomerFromOrder")
75+
default boolean mapCustomerFromOrder(OrderDTO dto) {
76+
return dto != null && dto.getCustomerName() != null;
77+
}
78+
79+
}
80+
{{< /prettify >}}
81+
82+
Then MapStruct would generate
83+
84+
{{< prettify java >}}
85+
public class OrderMapperImpl implements OrderMapper {
86+
87+
@Override
88+
public Order map(OrderDTO dto) {
89+
if ( dto == null ) {
90+
return null;
91+
}
92+
93+
Order order = new Order();
94+
95+
if ( mapCustomerFromOrder( dto ) ) {
96+
order.setCustomer( orderDtoToCustomer( orderDTO ) );
97+
}
98+
99+
return order;
100+
}
101+
}
102+
{{< /prettify >}}
103+
104+
In order for the same to be generated in 1.6, the mapper needs to look like this:
105+
106+
{{< prettify java >}}
107+
@Mapper
108+
public interface OrderMapper {
109+
110+
@Mapping(source = "dto", target = "customer", conditionQualifiedByName = "mapCustomerFromOrder")
111+
Order map(OrderDTO dto);
112+
113+
@SourceParameterCondition
114+
@Named("mapCustomerFromOrder")
115+
default boolean mapCustomerFromOrder(OrderDTO dto) {
116+
return dto != null && dto.getCustomerName() != null;
117+
}
118+
119+
}
120+
{{< /prettify >}}
121+
122+
### Download
123+
124+
This concludes our tour through MapStruct 1.6 RC1.
125+
If you'd like to try out the features described above, you can fetch the new release from Maven Central using the following GAV coordinates:
126+
127+
* Annotation JAR: [org.mapstruct:mapstruct:1.6.0.RC1](http://search.maven.org/#artifactdetails|org.mapstruct|mapstruct|1.6.0.RC1|jar)
128+
* Annotation processor JAR: [org.mapstruct:mapstruct-processor:1.6.0.RC1](http://search.maven.org/#artifactdetails|org.mapstruct|mapstruct-processor|1.6.0.Beta2|jar)
129+
130+
Alternatively, you can get ZIP and TAR.GZ distribution bundles - containing all the JARs, documentation etc. - [from GitHub](https://github.com/mapstruct/mapstruct/releases/tag/1.6.0.RC1).
131+
132+
If you run into any trouble or would like to report a bug, feature request or similar, use the following channels to get in touch:
133+
134+
* Get help in [GitHub Discussions](https://github.com/mapstruct/mapstruct/discussions) or [StackOverflow](https://stackoverflow.com/questions/tagged/mapstruct)
135+
* Report bugs and feature requests via the [issue tracker](https://github.com/mapstruct/mapstruct/issues)
136+
* Follow [@GetMapStruct](https://twitter.com/GetMapStruct) on Twitter

0 commit comments

Comments
 (0)