MapStruct v1.3.0.Beta2 Release Notes
Release Date: 2018-11-11 // over 5 years ago-
IMPORTANT: Starting from this version MapStruct uses Java 8 as a baseline (#1301)
๐ Features
- Apply source presence tracking recursively (#1456)
โจ Enhancements
- Avoid using
java.beans.Introspector
(#1524) - Cache
javax.xml.datatype.DatatypeFactory
(#1532) - Rename isBuilderSetter in isFluentSetter in the DefaultAccessorNamingStrategy (#1578) - NB : The
isBuilderSetter
was added in1.3.0.Beta1
- โ Add support for "adders" in combination with
java.util.stream.Stream
(#1561) - ๐ Allow
nullValueCheckStrategy
on@BeanMapping
(#1571) - ๐ Support for conversion between
java.time.Instant
andjava.util.Date
(#1595) - ๐ Use
javax.annotation.processing.Generated
if available (#1551) - Map
java.sql.Date
to ajava.time.LocalDate
(#1591) - ๐ When source is
null
target should NOT be set tonull
(#1306) - Added newNullValuePropertyMappingStrategy
. See PR #1618 and Behavior for more information - โ Adder wrapper should use singular from the source for the
Iterable
element (#1478) - โ Emit warnings for precision loss (#5)
- Introduce mechanism to report error from MappingResolver (#1458)
- 0๏ธโฃ Access to Types and Elements in AccessorNamingStrategy (#1253) - The
AccessorNamingStrategy
has been extended with a default init method that allows for initialising it with theElements
andTypes
utils through theMapStructProcessingEnvironment
- ๐ Use
MapStructProcessingEnvironment
for initialising theBuilderProvider
(#1640) - TheBuilderProvider
has been extended with the same init functionality as theAccessorNamingStrategy
- ๐ฒ Property error logging on
@Mapping
annotation (#1504) - ๐ FQN of
LocalDateTime
is used when a simple name is possible (#1576) - With this issue we have also optimised the way we store the required imports (see PR #1642 for more information)
๐ Bug fixes
- NPE when using varargs in mapping method (#1541)
- ZoneOffset not fully qualified (#1569)
- ๐ป Exception when processing mapping from constants/expressions to inner fields with multi-arg mapping (#1552)
- [Compilation Error] class
java.util.ArrayList
not found.MappersImpl
cannot be compiled. (#1590) - ๐ Generated code fails to build when the source type is a byte array annotated with
@NotNull
(#1558) - Fixes a generic problem for all usages of annotations withElementType.TYPE_VAR
- Missing imports for Immutables (#1596)
- Fluent setters starting with is are not correctly handled (#1608)
- Similar with #1148 (Nested target properties uses same method for different mappings) (#1594)
- ๐ Setters on a Builder super class are not called (#1566) - As part of this a new custom
AccessorNamingStrategy
has been added for FreeBuilder (see 104ebf8 for more information)
๐ Documentation
- โ Adding an issue template. PR #1616
๐ Build
- โ Add Integration tests with Protobuf (#1499)
- ๐ง Inherit configuration for sub classes using
@InheritConfiguration
(#1593) - Add tests to show it is working - ๐ Fix wrong line number in JDK for
@Repeatable
Mappings (#1633) - There is a bug in the javac compiler that does not report the diagnostics on the correct place. See JDK-8042710 and #1628 for tracking it on our side
Behavior
Nested source presence tracking
๐ With #1456 MapStruct now uses nested source presence tracking for nested objects. If the first property has a presence check method then a presence check would be checked recursively. See the issue description for what has changed.
Handling null or missing source properties
โก๏ธ With #1306 MapStruct now has a
NullValuePropertyMappingStrategy
that can be used to control hownull
or not present source properties are updated within a target. The possibilities are:SET_TO_NULL
- If the source property isnull
or not present the target property is set tonull
. This is also the default, which is the same behaviour from before.SET_TO_DEFAULT
- If the source property isnull
or not present the target property is set to default (empty list, empty set, new object instantiation etc)IGNORE
- If the source property isnull
or not present the target property is not set at all
NB : During this we noticed that we handle differently collections / maps for normal mapping methods (i.e. we were setting those to
null
if the source property wasnull
or not present). This is now changed and collections / maps won't be set if the source property is null or not present. In such case one needs to use@ObjectFactory
or set the default in the constructor of the target objectNB2 : In 1.2.0.Final with #1273 we added support for using
NullValueMappingStrategy#RETURN_DEFAULT
to control how collections / maps default values are set. We realized that this was a mistake on our side and now one should useNullValuePropertyMappingStrategy#SET_TO_DEFAULT
.๐ See this for more information as well
๐ BuilderProvider
๐ The
BuilderProvider
interface has been changed from 1.3.0.Beta1. Now it has an init method that can be used to get access to theElements
andTypes
utils and thefindBuilderInfo
method only gets theTypeMirror