This allows to easily avoid the runtime dependency on mapstruct.jar:
we can avoid Mappers.getMapper(...) for instantiating used mappers if
the code follows the conventional pattern for creating mapper singletons.
Co-authored-by: GIBOU Damien <damien.gibou@biomerieux.com>
Add a new custom EnumTransformationStrategy SPI which can be used for providing custom way of name based mapping for enums.
Add 4 out of the box transformation strategies:
* prefix - add a prefix to the name based enum mapping
* stripPrefix - remove a prefix from the name based enum mapping
* suffix - add a suffix to the name based enum mapping
* stripSuffix - remove a suffix from the name based enum mapping
This can be achieved by using the new `EnumMapping`
e.g.
Add suffix `_TYPE` to all enums:
`@EnumMapping(nameTransformationStrategy = "suffix", configuration = "_TYPE")`
With this it would be possible to achieve what is needed in #796, #1220, #1789.
By default the constructor argument names are used to extract the target properties.
If a constructor is annotated with an annotation named `@ConstructorProperties` (from any package) then it would be used to extract the target properties.
If a mapping target has a parameterless empty constructor it would be used to instantiate the target.
When there are multiple constructors then an annotation named `@Default` (from any package) can be used to mark a constructor that should be used by default when instantiating the target.
Supports mapping into Java 14 Records and Kotlin data classes out of the box
- Extended Type#getAlternativeTargetAccessors to recognize stream read
accessors for which no corresponding setter exists
(there is only an add method)
- Extended SourceRHS#getSourceTypeForMatching to return the
correct source type for streams too
- Add StreamAdderWrapper to map Stream -> Adder
- Extended PropertyMapping$PropertyMappingBuilder#assignToPlainViaAdder
to return StreamAdderWrapper if source type is stream
* Added getReferenceName() to Type which returns simple or fully-qualified-name
* Use getReferenceName() in all SimpleConversions
* Added testcase that is not working without these changes
* Added ConversionUtils with a lot of helper methods to create the "reference names" used in SimpleConversions
* The Value / Enum Mappings should copy all the parameters from the method that is being overriden
* The source parameter should be the first source parameter
If a SourceRHS is present then the source type of the SourceRHS and the MappingContext parameters are considered for the factory method selection, i.e. the other source parameters are ignored
* SetterWrapperForCollectionsAndMaps - Does a simple assignment without doing any null checks
* SetterWrapperForCollectionsAndMapsWithNullCheck - Does an assignment that does a null check before assignment and takes direct assignment into consideration
* ExistingInstanceSetterWrapperForCollectionsAndMaps - Used for wrapping an assignment when the method is an update method
Additionally don't do local var assignment if there are presence checkers