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 in 1.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 and java.util.Date (#1595)
    • ๐Ÿ‘‰ Use javax.annotation.processing.Generated if available (#1551)
    • Map java.sql.Date to a java.time.LocalDate (#1591)
    • ๐Ÿ‘€ When source is null target should NOT be set to null (#1306) - Added new NullValuePropertyMappingStrategy. 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 the Elements and Types utils through the MapStructProcessingEnvironment
    • ๐Ÿ— Use MapStructProcessingEnvironment for initialising the BuilderProvider (#1640) - The BuilderProvider has been extended with the same init functionality as the AccessorNamingStrategy
    • ๐ŸŒฒ 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 with ElementType.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 how null or not present source properties are updated within a target. The possibilities are:

    • SET_TO_NULL - If the source property is null or not present the target property is set to null. This is also the default, which is the same behaviour from before.
    • SET_TO_DEFAULT - If the source property is null or not present the target property is set to default (empty list, empty set, new object instantiation etc)
    • IGNORE - If the source property is null 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 was null 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 object

    NB2 : 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 use NullValuePropertyMappingStrategy#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 the Elements and Types utils and the findBuilderInfo method only gets the TypeMirror