Support for subclass mapping, various enhancements and much more: MapStruct 1.5.0.Beta2 is out
It’s my pleasure to announce the second Beta release of MapStruct 1.5.
The new release comes with new functionality and some bug fixes, e.g.:
- Support for subclass mapping
NullValueMappingStrategy
for maps / collections- New built-in conversions
- Generate imports only for Top level types
Altogether, not less than 32 issues were fixed for this release.
This would not have been possible without our fantastic community of contributors:
-
our latest MapStruct contributor Ben Zegveld
-
and of course seasoned MapStruct hackers Sjaak Derksen and Filip Hrisafov.
Thank you everyone for all your hard work!
After our first Beta release of 1.5 in the summer, we are proud to present you with the second Beta of the 1.5 release.
We’d like to thank our community for the feedback on our first Beta release and for their contributions. With this release we are happy to announce that our small team of contributors now includes Ben Zegveld.
Enough of the pep talk, let’s take a closer look at some of the new features and enhancement!
NullValueMappingStrategy for maps / collections
MapStruct has had the NullValueMappingStrategy
to control what to do when the source argument of the mapping method equals null
.
This strategy has controlled the mapping for beans, collections and maps.
Starting from this release there is an option to define different strategy for collections and maps separately through:
IterableMapping#nullValueMappingStrategy
,Mapper#nullValueIterableMappingStrategy
,MapperConfig#nullValueIterableMappingStrategy
- for collections / iterablesMapMapping#nullValueMappingStrategy
,Mapper#nullValueMapMappingStrategy
,MapperConfig#nullValueMapMappingStrategy
- for maps
New Built-In conversions
We have extensive number of built-in conversions between different types. As of this release we have 1 more:
- Between
String
andURL
Enhancements
- Diagnostics now show up on the Mapper type - All errors are now shown on the mapper type itself. This helps locate problems when extending from base mappers
- Generate imports only for top level classes
- Iterable type to non-iterable type error no longer reported when using multi source mapping
suppressTimestampInGenerated
in has been exposed in the@Mapper
annotation- Provide all available case transformations when an unknown is used in
CaseEnumTransformationStrategy
- Add
unmappedSourcePolicy
as an annotation processor argument
Breaking Changes
- Update methods with a return type always return the target object (annotated with
@MappingTarget
). Prior to this release update mappings with a return type returnednull
when the source parameter wasnull
.
Download
This concludes our tour through MapStruct 1.5 Beta2. 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:
- Annotation JAR: org.mapstruct:mapstruct:1.5.0.Beta2
- Annotation processor JAR: org.mapstruct:mapstruct-processor:1.5.0.Beta2
Alternatively, you can get ZIP and TAR.GZ distribution bundles - containing all the JARs, documentation etc. - from GitHub.
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:
- Get help in our Gitter room, the GitHub Discussion or StackOverflow
- Report bugs and feature requests via the issue tracker
- Follow @GetMapStruct on Twitter