Compare commits

...

1299 Commits

Author SHA1 Message Date
Yang Tang
e4bc1cdf1e
#3884 Ensure NullValuePropertyMappingStrategy.SET_TO_DEFAULT initializes empty collection/map when target is null
Signed-off-by: TangYang <tangyang9464@163.com>
2025-06-15 08:29:45 +02:00
Filip Hrisafov
c90c93630e #3886: Records do not have property write accessors (apart from the record components) 2025-06-14 23:40:02 +02:00
Filip Hrisafov
f4d1818171 Fix issue key in Issue3807Test 2025-06-14 21:33:26 +02:00
dependabot[bot]
d68819a233 Bump org.springframework:spring-context from 6.2.2 to 6.2.7 in /parent
Bumps [org.springframework:spring-context](https://github.com/spring-projects/spring-framework) from 6.2.2 to 6.2.7.
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v6.2.2...v6.2.7)

---
updated-dependencies:
- dependency-name: org.springframework:spring-context
  dependency-version: 6.2.7
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-14 17:02:12 +02:00
Filip Hrisafov
46ce011e4b
Refactor options and add an enum (#3877) 2025-06-01 07:52:18 +02:00
Filip Hrisafov
9847eaf195
#3876: Move Windows and Mac OS builds outside of the main workflow 2025-05-31 18:14:13 +02:00
Yang Tang
ce84c81de2
#3659: Support @AnnotatedWith on decorators
Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-31 17:52:05 +02:00
Yang Tang
bff88297e3
#3807: Properly recognize the type of public generic fields
Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-31 13:29:39 +02:00
Yang Tang
8fc97f5f62
#3806: Properly apply NullValuePropertyMappingStrategy.IGNORE for collections / maps without setters
Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-31 11:13:50 +02:00
Yang Tang
5464c3cff8
#3711: Support generic @Context
Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-31 11:10:24 +02:00
Aleksey Ivashin
6b6600c370
#1958: Add support for ignoring multiple target properties at once 2025-05-25 17:05:18 +02:00
Yang Tang
0badba7003
#3849: Resolve duplicate invocation of overloaded lifecycle methods with inheritance
Add compiler option `mapstruct.disableLifecycleOverloadDeduplicateSelector` to disable the deduplication if needed.

Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-25 16:35:38 +02:00
Yang Tang
3a5c70224d
#3809 Fix conditional mapping with @TargetPropertyName failing for nested update mappings
Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-25 15:40:43 +02:00
Şamil Can
42c87d1da9
#3848: Mark String to number as lossy conversion 2025-05-25 15:22:47 +02:00
Dennis Melzer
05f27e96e2
#3852 Initialize Optionals with empty instead of null 2025-05-25 14:58:23 +02:00
Yang Tang
6e6fd01a2e
#3821: Add support for custom exception for subclass exhaustive strategy for @SubclassMapping
---------

Signed-off-by: TangYang <tangyang9464@163.com>
2025-05-17 18:40:51 +02:00
roelmang
fce73aee6a #3729 Support for using inner class Builder without using static factory method 2025-05-11 21:58:47 +02:00
Filip Hrisafov
2fb5776350 Add release notes for next version 2025-05-11 20:07:53 +02:00
zral
602e29083f
#1140 Add warning when target has no properties 2025-05-11 19:59:59 +02:00
Cause Chung
2c84d04463 #3240 Add Support for Java21 SequencedSet and SequencedMap 2025-05-11 17:33:35 +02:00
dependabot[bot]
668eeb5de1 Bump com.google.protobuf:protobuf-java from 3.21.7 to 3.25.5 in /parent
Bumps [com.google.protobuf:protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.21.7 to 3.25.5.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/protobuf_release.bzl)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.21.7...v3.25.5)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-11 15:57:52 +02:00
fml2
d5f825193c
#3815: chore(docs): Improved wording about @Condition usage 2025-05-10 14:12:20 +02:00
Zegveld
39551242d7
#3786: Improve error message when mapping non-iterable to array 2025-01-24 14:41:35 +01:00
Filip Hrisafov
c08ba4ca7e
Update setup-java and checkout actions to v4 (#3804) 2025-01-22 08:51:49 +01:00
Filip Hrisafov
57d4f88a48
Java EA GitHub Actions improvements (#3803)
* Use Java 17 for building MapStruct (still Java 8 compatible)
* Upgrade to Spring 6 for tests
* Adjust excludes and min tests version for some integration tests
2025-01-20 07:56:19 +01:00
Filip Hrisafov
e0a7d3d0e6 Use latest Maven Wrapper 2025-01-19 15:05:59 +01:00
Tran Ngoc Nhan
8f96291911
Fix documentation typo and code polish (#3787) 2025-01-18 13:04:42 +01:00
Daniel Hammer
4812d2b030
Align README with v1.6.3 release (#3784) 2024-12-07 14:57:13 +01:00
jinhyogyeom
f98a742f98
Standardize Class Names to PascalCase in tests (#3773) 2024-12-01 11:22:51 +01:00
Tran Ngoc Nhan
084cf3abc1
Fix javadoc typos (#3780) 2024-11-29 09:33:41 +01:00
dudxor4587
f3d2b2e65b
Delete unnecessary conditions and modify return statement (#3772) 2024-11-21 23:14:16 +01:00
Roman Obolonskyi
737af6b50a
#3628 Add support for locale parameter for numberFormat and dateFormat 2024-11-17 16:46:59 +01:00
Minji Kim
bee983cd3c
Fix typos in comments (#3769) 2024-11-15 22:13:36 +01:00
hsjni0110
8de18e5a65
fix typos in method and variable names (#3766) 2024-11-13 21:35:20 +01:00
cussle
0df3f6af95
docs & refactor: fix typos and improve readability in multiple classes (#3767)
- AnnotatedConstructor: Fixed a variable name typo (noArgConstructorToInBecluded → noArgConstructorToBeIncluded).
- AbstractBaseBuilder: Improved Javadoc by fixing typos and clarifying wording.
- SourceRhsSelector: Corrected a typo in the class-level Javadoc.
- InheritanceSelector: Enhanced readability by fixing typos and refining comments.
2024-11-13 21:22:57 +01:00
GitHub Action
5bf2b152af Next version 1.7.0-SNAPSHOT 2024-11-09 11:40:01 +00:00
GitHub Action
b4e25e49de Releasing version 1.6.3 2024-11-09 11:31:12 +00:00
Filip Hrisafov
772fae4c77 Prepare release notes for 1.6.3 2024-11-09 12:20:14 +01:00
Filip Hrisafov
efdf435770 #3751 Improve readme to include support for Java 16+ records 2024-11-09 12:17:29 +01:00
Filip Hrisafov
c2bd847599 #3732 Do not generate obsolete imports for LocalDateTime <-> LocalDate conversion 2024-11-09 12:17:13 +01:00
Filip Hrisafov
21fdaa0f82 #3747 Do not generate redundant if condition with constructor mapping and RETURN_DEFAULT null value mapping strategy 2024-11-03 13:46:48 +01:00
Srimathi-S
32f1fea7b5
#3370 Prevent stack overflow error for Immutables with custom builder 2024-11-03 12:52:52 +01:00
Filip Hrisafov
26c5bcd923
Update readme with 1.6.2 2024-09-27 09:15:17 +02:00
GitHub Action
4e0d73db1d Next version 1.7.0-SNAPSHOT 2024-09-16 08:06:43 +00:00
GitHub Action
212607b447 Releasing version 1.6.2 2024-09-16 07:55:31 +00:00
Filip Hrisafov
4fd22d6b26 Prepare release notes for 1.6.2 2024-09-16 09:54:30 +02:00
Filip Hrisafov
a3b4139070 #3717 Fix ClassCastException when getting thrown types for a record accessor 2024-09-16 09:52:57 +02:00
GitHub Action
c74e62a94c Next version 1.7.0-SNAPSHOT 2024-09-15 16:01:43 +00:00
GitHub Action
10d69878a1 Releasing version 1.6.1 2024-09-15 15:52:17 +00:00
Filip Hrisafov
c36f9ae5d1 Prepare release notes for 1.6.1 2024-09-15 17:11:24 +02:00
Filip Hrisafov
3011dd77d7 #3678 before / after mapping for type using builder should only be kept if they are using the actual type in @TargetType or @MappingTarget 2024-09-15 16:45:21 +02:00
Filip Hrisafov
4c1df35ba6 #3703 Use include model instead of manually writing the type name for return type for afterMappingReferencesWithFinalizedReturnType 2024-09-15 16:45:08 +02:00
Filip Hrisafov
2686e852b6
#3661 Use correct type for the Record component read accessors 2024-09-14 01:17:45 +02:00
Filip Hrisafov
12c9c6c1f0 Use email variable for GitHub Bot git email 2024-09-06 16:35:37 +03:00
Filip Hrisafov
796dd94674 Update next release changelog with latest changes 2024-09-02 15:33:08 +02:00
Filip Hrisafov
5232df2707 Try to stabilise MapMappingTest and CarMapperTest 2024-09-02 15:18:37 +02:00
Obolrom
4d9894ba25
#3113 Use LinkedHashSet, LinkedHashSet new factory methods for java >= 19 2024-09-02 10:26:48 +02:00
김기서
23f4802374
Fix method name typo (#3691) 2024-09-02 09:05:01 +02:00
Obolrom
1e89d7497b
Fix method name typo (#3622) 2024-09-02 08:44:17 +02:00
hduelme
c6010c917a Fix typo in readme Maven plugin config 2024-08-31 16:34:54 +02:00
Filip Hrisafov
58dcb9d813
Update latest version and remove some obsolete badges 2024-08-28 11:56:21 +02:00
Filip Hrisafov
c89b616f8c
#3668 Do not apply implicit mappings when using SubclassExhaustiveStrategy#RUNTIME_EXCEPTION and return type is abstract 2024-08-24 12:22:37 +02:00
Filip Hrisafov
6c8a2e184b #3667, #3673 MappingReference should custom MappingOption equality instead of the default only target name based one 2024-08-24 11:29:28 +02:00
Filip Hrisafov
60cd0a4420
#3670 Fix regression when using InheritInverseConfiguration with nested target properties and reversing target = "." 2024-08-24 11:27:52 +02:00
Stefan Simon
b452d7f2c8
#3652 Inverse Inheritance should be possible for ignore-mappings without source 2024-08-18 17:46:35 +02:00
GitHub Action
96d0698417 Next version 1.7.0-SNAPSHOT 2024-08-12 21:08:07 +00:00
GitHub Action
38ec5c5335 Releasing version 1.6.0 2024-08-12 20:59:31 +00:00
thunderhook
81ca739040 #3638 Remove deprecation note of enum mapping via @Mapping 2024-07-25 10:40:12 +02:00
Filip Hrisafov
0f24633d04 Fix update website script to be able to run Linux 2024-07-20 18:05:08 +02:00
GitHub Action
6365a606c1 Next version 1.6.0-SNAPSHOT 2024-07-20 15:45:11 +00:00
GitHub Action
6ef64ea3aa Releasing version 1.6.0.RC1 2024-07-20 15:36:11 +00:00
Filip Hrisafov
bbb9bb403c Fix typo in changelog 2024-07-20 17:21:29 +02:00
Filip Hrisafov
5ce9c537e9 Add release notes 2024-07-20 16:29:17 +02:00
Filip Hrisafov
e2edb1a086 #3504 Add example classes for the passing target type documentation 2024-07-20 16:26:38 +02:00
Stefan Simon
3047760fd0
#3591 Fix duplicate method generation with recursive auto mapping 2024-07-20 16:19:59 +02:00
Obolrom
df49ce5ff9
#3609 Pass bean mapping ignored unmapped source properties to subclass forged methods
Co-authored-by: thunderhook <8238759+thunderhook@users.noreply.github.com>
2024-07-20 14:06:49 +02:00
Filip Hrisafov
66f4288842
#3601 Always use SourceParameterCondition when checking source parameter
This is a breaking change, with this change whenever a source parameter is used as a source for a target property the condition has to apply to source parameters and not properties
2024-07-20 13:53:39 +02:00
thunderhook
52877d36c2 #3634 fix typo in experimental note 2024-07-20 13:06:00 +02:00
thunderhook
eef3bdfca4 #3639 fix documentation link 2024-07-20 13:05:28 +02:00
hduelme
8fa2f40944
Enforce whitespaces around the for colon with CheckStyle (#3642) 2024-07-15 23:18:32 +02:00
Connor McGowan
037da5a1e1
#3635 Fix documentation of unmappedSourcePolicy default (#3637) 2024-07-07 21:19:38 +02:00
Filip Hrisafov
69371708ee
#3574 Respect only explicit mappings but fail on unmapped source fields
* #3574 Respect only explicit mappings but fail on unmapped source fields

This reverts #2560, because we've decided that `@BeanMapping(ignoreByDefault = true)` should only be applied to target properties and not to source properties.
Source properties are anyway ignored, the `BeanMapping#unmappedSourcePolicy` should be used to control what should happen with unmapped source policy
2024-07-06 10:31:32 +02:00
Filip Hrisafov
babb9dedd9 #3602 Doing a release should reset NEXT_RELEASE_CHANGELOG.md 2024-06-30 14:47:27 +02:00
Filip Hrisafov
baa02bf377 #3602 Fix path for update-website.sh scrip in release workflow 2024-05-11 09:32:41 +02:00
GitHub Action
8a679b325d Next version 1.6.0-SNAPSHOT 2024-05-11 07:10:47 +00:00
GitHub Action
21a8b88a0f Releasing version 1.6.0.Beta2 2024-05-11 07:01:58 +00:00
Filip Hrisafov
8e53b4181f #3602 Fix setup-java action for release workflow 2024-05-11 08:47:39 +02:00
Filip Hrisafov
9a5e6b1892
#3602 Automate release with JReleaser
Add JReleaser for automating the release and add a step for automating the publishing of the website
2024-05-11 08:27:20 +02:00
Filip Hrisafov
b33942a010 #3561 Add test case 2024-05-01 08:15:44 +02:00
Filip Hrisafov
0a2a0aa526
#2610 Add support for conditions on source parameters + fix incorrect use of source parameter in presence check method (#3543)
The new `@SourceParameterCondition` is also going to cover the problems in #3270 and #3459.
The changes in the `MethodFamilySelector` are also fixing #3561
2024-04-29 08:05:52 +02:00
Filip Hrisafov
0a935c67a7 #3565 Presence check methods should not be considered as valid mapping candidates 2024-04-28 20:22:53 +02:00
Zegveld
5fbd36c443
#3577 Improve Mapping#ignoreByDefault documentation 2024-04-28 20:20:11 +02:00
hduelme
8e66445fe9
#3564 Correct issue key for Issue3485Test 2024-04-02 12:00:41 +02:00
Oliver Erhart
e815e3cb1e
#3524 Provide tests with Lombok style super builders 2024-03-10 09:15:37 +01:00
hduelme
2c12e75bfc
#3485 Exception for Mapping to target = "." without source 2024-03-03 18:59:32 +01:00
Filip Hrisafov
c374b5267f
#3360 Do not report unmapped source and target properties when result type is abstract due to runtime exception subclass exhaustive strategy (#3526) 2024-02-11 19:53:38 +01:00
Zegveld
bb1cd63485
#2788 Improve unmapped source properties message for forged methods 2024-02-11 13:29:34 +01:00
Filip Hrisafov
ca1fd0d85d
#3331 Do not handle defined mappings if the result type is abstract due to runtime exception subclass exhaustive strategy (#3487) 2024-02-11 12:51:19 +01:00
Oliver Erhart
8191c850e0
#3323 Support access to the source property name 2024-02-11 10:42:23 +01:00
hduelme
0a43bc088f
Add missing generic type to Javadoc Builder (#3499) 2024-01-28 18:07:57 +01:00
hduelme
90a3ce0b46
Use primitive types in NativeTypes (#3501) 2024-01-28 18:06:42 +01:00
Chanyut Yuvacharuskul
6830258f77
Fix typo in chapter-10-advanced-mapping-options.asciidoc (#3500) 2024-01-28 17:51:57 +01:00
hduelme
6322138028
Add missing generic diamond operator to MappingOptions (#3498) 2024-01-28 17:50:33 +01:00
Filip Hrisafov
60f162ca88
#3463 DefaultBuilderProvider should be able to handle methods in parent interfaces 2024-01-28 17:47:39 +01:00
Filip Hrisafov
6cb126cd7c
#3462 Stream getters should not be treated as alternative setter 2023-12-31 09:34:34 +01:00
Oliver Erhart
7e6fee8714
#1064 Provide a switch to turn off CheckStyle on generated test sources 2023-12-27 13:40:04 +01:00
Filip Hrisafov
6d99f7b8f3
#3473 Add Java 21 and EA to build matrix
Fix tests not running green on Java 21
Update Spring to run correctly on Java 21
2023-12-18 07:35:26 +01:00
mosesonline
fa857e9ff4
bump some lib versions (#3460) 2023-12-10 15:26:47 +01:00
Ravil Galeyev
930f5709b6
#3400 Remove unnecessary casts to long and double 2023-11-29 22:25:22 +01:00
Muhammad Usama
2bb2aefed8
#3413 Using Mapping#expression and Mapping#conditionaQualifiedBy(Name) should lead to compile error 2023-11-24 06:34:15 +01:00
wandi34
2af291ce2f
Fix Typo Mappper in SubclassMapping Doc 2023-11-11 21:48:52 +01:00
Filip Hrisafov
04deac2b3a [maven-release-plugin] prepare for next development iteration 2023-11-04 23:06:17 +01:00
Filip Hrisafov
0ac0c42dbc [maven-release-plugin] prepare release 1.6.0.Beta1 2023-11-04 23:06:16 +01:00
Oliver Erhart
79f01e2de0
Change master to main branch and fix CI status badge (#3423) 2023-11-04 21:35:40 +01:00
Oliver Erhart
b77d321ffb
Added recent contributors (including myself) 2023-11-01 00:01:45 +01:00
Xiu Hong Kooi
5d39314bd2
#3376 support mapping from iterables to collection 2023-10-31 23:55:11 +01:00
Filip Hrisafov
c59eca2a77
#3361 Inheriting mappings should only be applied if the target has been redefined 2023-09-30 21:52:07 +02:00
dependabot[bot]
97c389d58b Bump org.codehaus.plexus:plexus-utils from 3.0.20 to 3.0.24 in /parent
Bumps [org.codehaus.plexus:plexus-utils](https://github.com/codehaus-plexus/plexus-utils) from 3.0.20 to 3.0.24.
- [Release notes](https://github.com/codehaus-plexus/plexus-utils/releases)
- [Commits](https://github.com/codehaus-plexus/plexus-utils/compare/plexus-utils-3.0.20...plexus-utils-3.0.24)

---
updated-dependencies:
- dependency-name: org.codehaus.plexus:plexus-utils
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-30 11:11:47 +02:00
Nikolas Charalambidis
032ee4d77a #3374 Lombok compatibility documentation 2023-09-17 09:44:31 +02:00
GVladi
f61a3acec3 #3089 Improve support for Map attributes for Immutables
Co-Authored-By: thunderhook <8238759+thunderhook@users.noreply.github.com>
2023-09-16 10:56:52 +02:00
Filip Hrisafov
ea997f83ce
#2340 Add FUNDING.yml 2023-08-19 10:09:36 +02:00
Ben Zegveld
8cc2bdd092 #3163: Strip wild card when checking for type assignability 2023-08-13 09:26:53 +02:00
Zegveld
721288140a
Feature/2663 (#3007)
#2663 Fix for 2-step mapping with generics.

---------

Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
2023-08-04 10:14:53 +02:00
Filip Hrisafov
812faeef51 Use presence checks for checking source parameter presence
Instead of explicitly doing a null check use a PresenceCheck mechanism for
* BeanMappingMethod
* ContainerMappingMethod
* MapMappingMethod
2023-08-01 15:41:19 +02:00
Anton Erofeev
b2dc64136d
#3292 Simplify expressions, remove redundant expressions 2023-08-01 14:17:50 +02:00
Venkatesh Prasad Kannan
279ab22482
#3309 Add BeanMapping#unmappedSourcePolicy 2023-08-01 09:48:20 +02:00
Filip Hrisafov
28d827a724 Add test case for subclass mapping and bean mapping ignore by default 2023-07-30 10:39:10 +02:00
Lucas Resch
0460c373c0
#3229: Implement InjectionStrategy.SETTER 2023-07-30 10:38:24 +02:00
Roberto Oliveira
230e84efd1 #3340 Update tarLongFileMode to use POSIX 2023-07-29 09:13:55 +02:00
Filip Hrisafov
4abf2d4202 #3317 Do not generate source parameter if check for only primitives 2023-07-09 15:01:06 +02:00
Filip Hrisafov
53c73324ff #3310 Make sure that adders work properly when they are in a generic class 2023-07-09 15:00:57 +02:00
Zegveld
04434af17a
#3296: Skip default and static methods when determining prototype methods 2023-07-08 18:03:56 +02:00
dependabot[bot]
1b1325da6d Bump guava from 29.0-jre to 32.0.0-jre in /parent
Bumps [guava](https://github.com/google/guava) from 29.0-jre to 32.0.0-jre.
- [Release notes](https://github.com/google/guava/releases)
- [Commits](https://github.com/google/guava/commits)

---
updated-dependencies:
- dependency-name: com.google.guava:guava
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-16 12:37:01 +02:00
Filip Hrisafov
86919c637f
#3144 Map to Bean should only be possible for single source mappings and if explicitly used in multi source mappings 2023-05-28 09:55:40 +02:00
Filip Hrisafov
d075d9a5b6 Upgrade Freemarker to 2.3.32 2023-05-27 15:55:15 +02:00
Filip Hrisafov
62d1bd3490
#3280 Refactor method selection and use a context to be able to more easily access information 2023-05-27 15:04:34 +02:00
Filip Hrisafov
c2eed45df1 #3126 Apply target this references in the BeanMappingMethod 2023-05-27 11:17:01 +02:00
Oliver Erhart
51f4e7eba9
#3231 Prefer record constructor annotated with @Default 2023-05-24 06:04:13 +02:00
José Carlos Campanero Ortiz
84c443df9c
#3245 Remove redundant null checks in nested properties 2023-05-24 05:44:36 +02:00
Oliver Erhart
6d205e5bc4
#1454 Support for lifecycle methods on type being built with builders
Add missing support for lifecycle methods with builders:

* `@BeforeMapping` with `@TargetType` the type being build
* `@AftereMapping` with `@TargetType` the type being build
* `@AfterMapping` with `@MappingTarget` the type being build
2023-05-21 22:49:41 +02:00
paparadva
7c90592d05 #2863 Add validation of String type to @TargetPropertyName 2023-05-21 22:21:34 +02:00
Filip Hrisafov
efaa67aadf #3104 Update methods with NullValuePropertyMappingStrategy.IGNORE should use SetterWrapperForCollectionsAndMapsWithNullCheck 2023-05-20 17:04:59 +02:00
Filip Hrisafov
a89c34f00c #3238 Compile error instead of null pointer exception for invalid ignore with target this 2023-05-20 17:04:22 +02:00
Jason Bodnar
d0e4c48228
#3172 Add mapping between Locale and String 2023-05-08 22:23:03 +02:00
Zegveld
bc5a877121
#3054: Allow abstract return type when all directly sealed subtypes are covered by subclass mappings
Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
2023-05-01 11:54:24 +02:00
dependabot[bot]
be94569791 Bump protobuf-java from 3.21.2 to 3.21.7 in /parent
Bumps [protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.21.2 to 3.21.7.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/main/generate_changelog.py)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.21.2...v3.21.7)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-01 11:32:21 +02:00
MengxingYuan
f3dac94701
#2781 Remove unmapped source properties when source parameter is directly mapped 2023-05-01 10:28:51 +02:00
Etien Rožnik
4843123e6e
#3165 Support adders for array / iterable to collection 2023-05-01 09:42:58 +02:00
José Carlos Campanero Ortiz
a8df94cc20
#2987 Support for defining Javadoc in the generated mapper implementation 2023-05-01 09:22:59 +02:00
todzhang's cloudsdocker
970984785d
Update one typo in JavaDoc (#2938) 2023-05-01 09:12:23 +02:00
Bragolgirith
d3b4a168b7
#3199 Add support for implicit conversion between java.time.LocalDate and java.time.LocalDateTime 2023-05-01 09:11:05 +02:00
ro0sterjam
931591a385
#3071 Support defining custom processor options by custom SPI 2023-04-30 17:02:39 +02:00
Zegveld
2f78d3f4e2
#3125: Allow subclassmapping inheritance for methods with identical signature
Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
2023-04-30 16:33:00 +02:00
Filip Hrisafov
1ab5db6a27
Update latest release version to 1.5.5.Final 2023-04-23 22:20:05 +02:00
Filip Hrisafov
86a668661a #3159 Do null value check for collections with default expression 2023-04-23 18:30:08 +02:00
Filip Hrisafov
1bc3436c5c #3239 Mapping composition is no longer experimental 2023-04-22 22:31:03 +02:00
Filip Hrisafov
979b35a2f4 #3153 Do not use compress directive to strip whitespaces for value mapping switch method
When using the compress directive it is going to strip whitespaces from the templates as well (i.e. what the user defined in `ValueMapping#source` and / or `ValueMapping#target
2023-04-22 19:32:02 +02:00
Filip Hrisafov
e69843f46e #3158 BeanMapping#ignoreByDefault should work properly for constructor properties 2023-04-22 19:31:30 +02:00
Filip Hrisafov
c6ea69eaf9 #3186 Do not use conversions in 2-step mapping when they are disabled 2023-04-22 19:31:01 +02:00
Filip Hrisafov
d10d48ccff #3248 BeanMapping#ignoreUnmappedSourceProperties should be inherited for @InheritConfiguration 2023-04-22 19:21:28 +02:00
Claudio Nave
b1034e6703 #3202 Improve line location report for invalid qualifier for SubclassMapping 2023-04-22 18:16:07 +02:00
Filip Hrisafov
9adcb06c34 #3236 Add missing jakarta-cdi to the documentation 2023-04-22 17:46:27 +02:00
Filip Hrisafov
00f891be58 #3112 Add missing brackets 2023-04-22 17:14:46 +02:00
Johnny Lim
3c81d36810
Polish links in docs (#3214) 2023-04-16 21:51:33 +02:00
Filip Hrisafov
162fdb44f4
#3195 Update the location for asking questions 2023-04-16 10:17:32 +02:00
Ben Zegveld
03563d8ffe #3174 Also allow multiple SubclassMapping annotations on an annotation @interface. 2023-04-15 18:31:12 +02:00
Filip Hrisafov
6e9fa87ba9
#3142 Nested forged methods should declare throws from lifecycle methods 2023-04-13 21:52:15 +02:00
Filip Hrisafov
2be1f306a1 #3135 BeanMapping#mappingControl should be inherited by forged methods 2023-04-13 21:50:40 +02:00
José Carlos Campanero Ortiz
62c7ce1cdf
#3112 Document <THROW_EXCEPTION> in the reference guide 2023-04-13 21:48:13 +02:00
Claudio Nave
89db26a1af
#3119 Add qualifiedBy and qualifiedByName to SubclassMapping annotation 2023-03-17 09:06:13 +01:00
Claudio Nave
a7ba12676d
#3110 Fix throws declaration for ValueMapping annotated methods (#3122)
#3110 Fix throws declaration for ValueMapping annotated methods
2023-02-05 12:17:02 +01:00
Filip Hrisafov
fd27380185
#2953 Add support for globally defining nullValueMapMappingStrategy and nullValueIterableMappingStrategy 2022-11-13 14:22:25 +01:00
Filip Hrisafov
82b19b0d8a #3077 Add test case 2022-11-13 14:21:03 +01:00
Zegveld
8894cd5935
#3057: limit do not allow self to subclassmappings. (#3063)
* #3057: limit do not allow self to subclassmappings.
* #3057: determine method candidates after all other fields are set in the constructor.

Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
Co-authored-by: Filip Hrisafov <filip.hrisafov@gmail.com>
2022-11-04 14:21:05 +01:00
Filip Hrisafov
16e3ceadec
#2952 Do not treat a getter as an alternative write accessor when using CollectionMappingStrategy#TARGET_IMMUTABLE 2022-11-03 23:29:47 +01:00
Orange Add
93f7c3b8ea
#3015 Fix annotations to the forged methods 2022-11-03 23:22:35 +01:00
Orange Add
6a394ad466
#3037 Support @ValueMapping in meta annotations 2022-11-03 23:21:43 +01:00
Orange Add
bb099a55ee
#3040: Allow using only BeanMapping#mappingControl 2022-11-03 22:02:58 +01:00
Filip Hrisafov
81b2f70dac #3039 Upgrade FreeMarker to 2.3.31 2022-11-03 21:49:06 +01:00
Filip Hrisafov
a5d3542c24 Update latest release version to 1.5.3.Final 2022-10-07 20:43:15 +02:00
Filip Hrisafov
481ab36ca3 #3036 Add missing exclude to full feature test 2022-10-03 21:16:25 +02:00
Filip Hrisafov
3a325ea66b
#3036 Fix compile errors when intersection types are used in lifecycle methods 2022-10-03 21:12:19 +02:00
Filip Hrisafov
266c5fa41c
#1216 Pick candidate method with most specific return type
When there are multiple candidate methods returning different types.
We should be able to use the method with the most specific return type (if such a method exists)
2022-10-02 19:20:13 +02:00
Zegveld
411cc24dac
#2955 Fix @AfterMapping with return type not called for update mappings 2022-10-02 09:34:03 +02:00
José Carlos Campanero Ortiz
90a487ac06
#1427 Add support for custom name in Spring stereotype annotations 2022-10-01 13:47:49 +02:00
Filip Hrisafov
af1eab0ece
#2743 BeanMappingOptions should not be inherited for forged methods 2022-09-29 22:10:27 +02:00
Zegveld
608d476ed2
#3018: Use MappingControl with SubclassMapping 2022-09-29 21:35:51 +02:00
Orange Add
e979f506fa
#2773 Copy @Deprecated annotation from method or mapper to implementation 2022-09-28 22:17:59 +02:00
Filip Hrisafov
73e8fd6152
#2840, #2913, #2921: MethodMatcher should not match widening methods
In the MethodMatcher we need to do a special check when the target type is primitive.
The reason for that is that a Long is assignable to a primitive double.
However, doing that means that information can be lost and thus we should not pick such methods.
When the target type is primitive, then a method will be matched if and only if boxed equivalent of the target type is assignable to the boxed equivalent of the candidate return type
2022-09-27 09:35:54 +02:00
Johnny Lim
811cd569bb
Javadoc and documentation polishing (#3026) 2022-09-26 19:02:01 +02:00
Filip Hrisafov
8d670e7db7 #3008 Replace old issue template with new GitHub issue form templates 2022-09-21 22:10:42 +02:00
Prasanth Omanakuttan
d593afed69
Avoid unnecessary unboxing of Boolean (#3003) 2022-09-12 18:45:22 +02:00
José Carlos Campanero Ortiz
97c6755288
#2963 Add support for enum to integer conversion 2022-09-04 13:58:10 +02:00
Iaroslav Bogdanchikov
bbf63ae177
#2730 Add support for Jakarta XML Binding 2022-09-02 22:04:01 +02:00
Filip Hrisafov
21069e5a2e #2895 Generate more readable annotations 2022-09-02 17:24:37 +02:00
Prasanth Omanakuttan
68571de01b Update Typos in java-doc
Closes #2989
2022-08-29 21:32:00 +02:00
Orange Add
3cc2aa7675
#2825 Fix SubclassMapping stackoverflow exception 2022-08-28 12:41:25 +02:00
Orange Add
ac356cab25
#2983 Add @AnnotateWith support to non bean mapping methods 2022-08-28 12:33:46 +02:00
Filip Hrisafov
4708f4b2aa #2950 Disable CDI in the full features tests on Java 8 2022-08-26 19:36:51 +02:00
Filip Hrisafov
4fa66229d9
#2990 Stabilise top level imports 2022-08-26 19:35:54 +02:00
Taihao Zhang
3f798744ac
Fix typo in docs (#2982) 2022-08-24 19:40:08 +02:00
Filip Hrisafov
853e7b27df
#2925 Fix IllegalArgumentException when resolving generic parameters
When resolving the parameter for a method like:

```
<T> Optional<T> from(T value)
```

There was an exception in javac because getting a DeclaredType from an Optional
with a primitive type argument throws an exception.
Therefore, when assigning the type arguments we get the boxed equivalent.
This problem does not happen in the Eclipse compiler
2022-08-24 19:39:09 +02:00
Filip Hrisafov
42500ca755 #2907 Add test case for nested import of array 2022-08-24 19:38:40 +02:00
Filip Hrisafov
71b1a7b8a2 #2945 Stabilise top level imports
Make sure that GeneratedType always gets the imported types
from a Type before adding them
2022-08-24 19:38:40 +02:00
Filip Hrisafov
b24e831cf0
#2937 Fix conditional check for collections with adders 2022-08-24 19:11:52 +02:00
Filip Hrisafov
237543c47c
#2897 Always import types defined in Mapper#imports 2022-08-24 18:59:31 +02:00
Filip Hrisafov
fd4a2548b3 #2928 Add IntelliJ and Eclipse plugin information 2022-08-24 18:55:05 +02:00
Filip Hrisafov
874bf1fd2c
#2950 Add support for Jakarta CDI 2022-08-24 18:38:44 +02:00
Filip Hrisafov
ef4c26b075
#2949 Do not inverse inherit BeanMapping#ignoreUnmappedSourceProperties 2022-08-24 18:36:43 +02:00
Filip Hrisafov
3e0c62ac36 Publish snapshots when on main 2022-08-21 11:26:42 +02:00
Filip Hrisafov
4118a44630 #2974 Fix typos in documentation
Closes #2974
2022-08-21 10:56:25 +02:00
Hakan
54321d6e66
#2839 Keep thrown types when creating a new ForgedMethod with the same arguments
This fixes a compilation error when mapping fields with the same type due to not wrapping in a `try-catch` block
2022-08-20 15:23:32 +02:00
Prasanth Omanakuttan
46900cabde
Update Typos in javadoc (#2958) 2022-08-20 13:37:43 +02:00
Zegveld
17997ef617
#2901: Fix @TargetType annotation on a @Condition annotated method for a Collection value 2022-08-20 13:01:47 +02:00
Zegveld
849085e026
#1574: Support for annotating the generated code with custom annotations
Add new `@AnnotateWith` annotation.
This annotation can be used to instruct the MapStruct processor
to generate custom annotations in the generated code.
2022-08-20 12:59:38 +02:00
Nikola Ivačič
8fa286fe4c #2688: Support accessing to the target property name 2022-08-01 19:17:33 +02:00
dependabot[bot]
62e73464b2 Bump kotlin-stdlib in /integrationtest/src/test/resources/kotlinDataTest
Bumps [kotlin-stdlib](https://github.com/JetBrains/kotlin) from 1.3.70 to 1.6.0.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.6.0/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.3.70...v1.6.0)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-stdlib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-24 17:55:38 +02:00
Cassius Vinicius de Magalhães
6914889510 Update Chapter 11.2 - Inverse Mappings
Clarification of the inverse mapping usage.
2022-07-14 21:30:16 +02:00
Filip Hrisafov
dd5ac3b637 #2929 Improve documentation for BeanMapping#ignoreByDefault 2022-07-09 21:35:36 +02:00
Iaroslav Bogdanchikov
4b43f9079d #2922 Fix protobuf tests for M1 Macs 2022-07-08 20:35:26 +02:00
fml2
a2b4454a66 fix(docs): No Lombok classes in the runtime 2022-07-01 17:47:55 +02:00
Filip Hrisafov
de8c0c7070 Use UTF-8 when compiling the tests
The test infrastructure that we are using should use UTF-8 for generating the StandardJavaFileManager
2022-06-29 08:37:50 +02:00
Ben Zegveld
88745d151e #2882: target type is now correctly passed on through the MethodReferencePresenceCheck to the MethodReference. 2022-06-18 23:32:26 +02:00
Filip Hrisafov
07d144ebd1 Update readme with latest released 1.5.2.Final release 2022-06-18 19:11:39 +02:00
Filip Hrisafov
1459aabfc3 [maven-release-plugin] prepare for next development iteration 2022-06-18 19:01:18 +02:00
Filip Hrisafov
19973ff818 [maven-release-plugin] prepare release 1.5.2.Final 2022-06-18 19:01:16 +02:00
Sergei Portnov
406ae3fc13
#2891 Fix subclass mapping while superclass has non-empty constructor
Co-authored-by: Filip Hrisafov <filip.hrisafov@gmail.com>
2022-06-18 18:47:07 +02:00
Filip Hrisafov
98eb46aee9
#2880 Fix missing import for array mapping methods
Co-authored-by: Martin Kamp Jensen <martin.kamp.jensen@se.com>
2022-06-18 13:59:03 +02:00
Filip Hrisafov
fa800926e7 #2837 Add support for text blocks in expressions 2022-06-18 12:32:05 +02:00
Filip Hrisafov
22ad9f636d
#2806 Try to stabilise some date conversion tests by locking them on reading the default timezone 2022-06-14 22:03:32 +02:00
Filip Hrisafov
05ae9922ea Update GitHub actions
Run tests with Java 18
Change actions/checkout to v3
Change actions/setup-java to v3
2022-06-14 22:01:43 +02:00
Filip Hrisafov
d7c0d15fe1 Change required Java version for running MapStruct in the readme 2022-06-05 15:58:37 +02:00
Filip Hrisafov
9247c5d7fb #2870 Use codecov action v2 2022-06-05 13:22:37 +02:00
Filip Hrisafov
4c9aa00369 Update readme with latest released 1.5.1.Final release 2022-06-05 08:53:10 +02:00
Filip Hrisafov
20e97714d4 [maven-release-plugin] prepare for next development iteration 2022-06-05 08:42:56 +02:00
Filip Hrisafov
ec9288ce66 [maven-release-plugin] prepare release 1.5.1.Final 2022-06-05 08:42:55 +02:00
Filip Hrisafov
46b78bfe59 #2867 Fix NPE when reporting message on parent mappers 2022-06-05 08:35:31 +02:00
Filip Hrisafov
0726563024 Update readme with latest released 1.5.0.Final release 2022-06-02 23:30:17 +02:00
Filip Hrisafov
5efe5e291c [maven-release-plugin] prepare for next development iteration 2022-06-02 23:11:41 +02:00
Filip Hrisafov
efa11ba312 [maven-release-plugin] prepare release 1.5.0.Final 2022-06-02 23:11:41 +02:00
Filip Hrisafov
a1a0786cf2
#2846 Add test case showing that everything works as expected 2022-06-02 22:14:42 +02:00
Zegveld
0559c47c21
#2739 Enhance documentation around SPI usage 2022-05-30 21:51:57 +02:00
Filip Hrisafov
c945ccd628 #2835 Upgrade jacoco-maven-plugin to latest 0.8.8 to support Java 17 2022-05-30 21:50:13 +02:00
Filip Hrisafov
9769f51756 #2851 Fix typo in readme 2022-05-30 21:49:57 +02:00
Hao Zhang
a4162809a4
Doc: correct the annotation processor version (#2859)
The lombok-mapstruct-binding anotation procossor version given by document will result a compile problem, correct it by the example repository so that work fine
2022-05-28 11:37:21 +02:00
Zegveld
437a70d6df
#2807: Include LifeCycleMethod importTypes in the list of importTypes. (#2808)
Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
2022-04-08 20:57:40 +02:00
Filip Hrisafov
6604617730 #2794 Compile error when condition expression used with constant or expression 2022-04-03 15:20:00 +02:00
Zegveld
03d44b5a87
#2795: use 'includeModel' for the 'sourcePresenceCheckerReference' in the 'UpdateWrapper'. (#2796)
* #2795: use 'includeModel' for the 'sourcePresenceCheckerReference' in the 'UpdateWrapper'.
* Simplify the tests

Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
Co-authored-by: Filip Hrisafov <filip.hrisafov@gmail.com>
2022-04-02 18:55:06 +02:00
Zegveld
2473c3eaaa
#2797: Add the nested type import types in the NestedPropertyMappingMethod
* #2797: Reproduction scenario
* Add the nested type import types in the NestedPropertyMappingMethod

Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
Co-authored-by: Filip Hrisafov <filip.hrisafov@gmail.com>
2022-04-02 11:59:25 +02:00
dependabot[bot]
07eeea6bc9 Bump spring-beans from 5.3.15 to 5.3.18 in /parent
Bumps [spring-beans](https://github.com/spring-projects/spring-framework) from 5.3.15 to 5.3.18.
- [Release notes](https://github.com/spring-projects/spring-framework/releases)
- [Commits](https://github.com/spring-projects/spring-framework/compare/v5.3.15...v5.3.18)

---
updated-dependencies:
- dependency-name: org.springframework:spring-beans
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-02 11:25:14 +02:00
Filip Hrisafov
08a0313840 [maven-release-plugin] prepare for next development iteration 2022-03-21 08:14:09 +01:00
Filip Hrisafov
7e00af6ff4 [maven-release-plugin] prepare release 1.5.0.RC1 2022-03-21 08:14:08 +01:00
Filip Hrisafov
190b486b79
Add users that have contributed post 1.5.0.Beta2 to copyright.txt 2022-03-19 12:09:30 +01:00
Chris DeLashmutt
ab52867831
#2748 Support mapping map keys with invalid chars for methods 2022-03-19 11:51:19 +01:00
Filip Hrisafov
ad00adfa86
#2538 Allow using 2 step mappings with only one of the 2 methods being qualified 2022-03-12 23:57:17 +01:00
Zegveld
0a69492983
#2755: use raw Type when calling a static method. (#2762) 2022-03-12 18:02:01 +01:00
Zegveld
b6a3aa1512
#2758: fallback to param.variableName if ext.targetBeanName is not present in MethodReference handling. (#2759) 2022-03-12 18:01:15 +01:00
Filip Hrisafov
0b2c7e58b2
Add Christian Kosmowski to the copyright.txt 2022-02-23 15:55:20 +01:00
Zegveld
9b434f80f8
#2715: Updated documentation to reflect impact of conditions on update mappers. (#2740)
* #2715: added an example with an update mapper for Conditional behavior.
2022-02-06 20:05:42 +01:00
Zegveld
7bb85d05c0
2696: Invert @SubclassMappings with @InheritInverseConfiguration. (#2708)
* #2696: Added support for '@InheritInverseConfiguration' with '@SubclassMappings'.
* #2696: Overriding of inverse inheritence implemented. New order has preference over inherited order.
2022-02-06 20:03:23 +01:00
Filip Hrisafov
2a2c11e871
#2629 Use ModuleElement when getting type element
Prior to this MapStruct would only use `Elements#getTypeElement`.
With this PR if the mapper being generated is within a module MapStruct will use that module
for the methods that are needed (getTypeElement and getPackageElement).

Adapt the build to require a minimum Java 11 for building the processor module.
Adapt the GitHub actions to properly run integration tests with Java 8
Ignore Java 9 usages for the animal-sniffer-plugin
2022-01-30 20:52:22 +01:00
Filip Hrisafov
37835a5607
#2677 Use type without bounds when looking for read / presence accessor in a SourceReference 2022-01-30 20:49:05 +01:00
Filip Hrisafov
12070186a4 #2567 Add support for Jakarta Injection
Support for Jakarta is done in 2 ways:

* current jsr330 component model - In this case Jakarta Inject will be used if javax.inject is not available
* new jakarta component model - In this case Jakarta Inject will always be used
2022-01-30 13:31:50 +01:00
Filip Hrisafov
aed3ff5295 #1997 Use builders to construct empty objects in update wrapper 2022-01-30 12:38:42 +01:00
Filip Hrisafov
464adc9143 #2682 Change RetentionPolicy of @DecoratedWith to CLASS
In some circumstances (used with other types of aggregating processors, e.g. Spring)
the Gradle incremental compilation works correctly only for classes annotated with the `CLASS` or `RUNTIME`
retention policy.

The `@DecoratedWith` is the only annotation from MapStruct that was `SOURCE` retention.
With this commit we are changing its retention policy in order for better compatibility with the Gradle Incremental compilation
2022-01-29 17:03:03 +01:00
Filip Hrisafov
5f4d355838
#1661 Add support for globally disabling builders 2022-01-29 11:46:34 +01:00
Filip Hrisafov
aade31f095 #2468 Update needed dependencies for running CDI tests on Java 16+ 2022-01-29 11:25:40 +01:00
Filip Hrisafov
20ff51ebb8
#2728 Add new WithTestDependency annotation for our processor testing
Adding this dependency allows us to dynamically pick the dependencies that we want to have on the test compilation classpath.
It would allow us to more granularly test things with different dependencies, such as javax inject and jakarta inject
2022-01-29 11:13:16 +01:00
Filip Hrisafov
ec30f5d279
#2725 Update tools-gem to 1.0.0.Alpha3 and run GitHub Action with Java 19-ea
Also update Spring to 5.3.15 to be able to run on Java 19
2022-01-29 11:03:44 +01:00
Zegveld
9105041522
#2668: Added support for collections and maps with a no-args constructor (#2671)
#2668: Added support for collections and maps with a no-args constructor. Added a compiler error in case of a collection or map without either a no-arg constructor or a copy constructor.
2022-01-29 00:37:24 +01:00
Justyna
b22efd9ad7
#2674: Add check if method without implementation doesn’t have @AfterMapping / @BeforeMapping annotation 2022-01-24 14:17:24 +01:00
Goni-Dev
0a8e9b738c
#2709 Corrected description for example demonstrating default expression 2022-01-23 17:26:21 +01:00
dependabot[bot]
0f297ae60f Bump protobuf-java from 3.6.0 to 3.16.1 in /parent
Bumps [protobuf-java](https://github.com/protocolbuffers/protobuf) from 3.6.0 to 3.16.1.
- [Release notes](https://github.com/protocolbuffers/protobuf/releases)
- [Changelog](https://github.com/protocolbuffers/protobuf/blob/master/generate_changelog.py)
- [Commits](https://github.com/protocolbuffers/protobuf/compare/v3.6.0...v3.16.1)

---
updated-dependencies:
- dependency-name: com.google.protobuf:protobuf-java
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-22 13:24:54 +01:00
Ben Zegveld
277b6f5d2b #2719: added a note at the builder documentation to point towards the Before-/AfterMapping documentation. 2022-01-22 13:12:06 +01:00
Filip Hrisafov
59c5f40ac3
#2686 Add documentation about when mappers are injected 2022-01-18 18:22:47 +01:00
Filip Hrisafov
f7f65ac1de #2687 Add documentation for NullValueMappingStrategy for collections and maps 2022-01-15 10:34:37 +01:00
Valentin Kulesh
42cfa05c40
#2704 Fix broken reference to constants within nested enums 2021-12-26 11:22:05 +01:00
Ben Zegveld
0a7b8134d4 #2689: documentation: fix example title. 2021-12-25 11:50:48 +01:00
Filip Hrisafov
930b07aab8 [maven-release-plugin] prepare for next development iteration 2021-12-12 12:48:56 +01:00
Filip Hrisafov
0de10ca83c [maven-release-plugin] prepare release 1.5.0.Beta2 2021-12-12 12:48:55 +01:00
Zegveld
ea45666d66
#2673: Fix optional wrapping pattern throwing exception when primitive types are present
MethodMatcher incorrectly reported that a primitive type matches a candidate for a type var
2021-12-11 14:16:19 +01:00
Filip Hrisafov
5de813c16f #2666 Presence Check should be applied to source parameters when used in @Mapping 2021-12-04 12:37:15 +01:00
Filip Hrisafov
00df0bc3d0
#2680 Refactor accessors
Split the `PresenceCheck`s accessor from the current `Accessor`.
Introduce a `ReadAccessor` that would allow us to more easily implement certain things.
Remove `MAP_GET` and `MAP_CONTAINS` from the AccessorType and use the new refactored mechanism
2021-12-03 19:13:41 +01:00
dersvenhesse
754aaf2ef4 [DOCS] Fixed reference variable 2021-12-03 19:10:25 +01:00
Filip Hrisafov
13bc0c023c
#2553 Support source property paths for maps 2021-11-20 08:48:08 +01:00
Filip Hrisafov
29008e12bf #2005 Parameter type should only be checked if we are mapping from a single argument source 2021-11-20 08:00:32 +01:00
Zegveld
72e6b1feb5
#2636: defaultValue combined with qualified should not convert if not needed (#2637) 2021-11-14 20:11:05 +01:00
Filip Hrisafov
735a5bef6a
#2225 Add support for suppressing the generation of the timestamp through Mapper and MapperConfig 2021-11-06 09:21:16 +01:00
Filip Hrisafov
166eb699c7 #1752 Always return mapping target when using update methods with return 2021-10-31 17:41:49 +01:00
Filip Hrisafov
907d605160 #2624 Nested target methods should be inherited for forged Map to Bean methods 2021-10-31 17:11:54 +01:00
Zegveld
ca2529f862
#598: Errors/Warnings now end up in the @Mapper annotated class. (#2634)
#598: Errors/Warnings now end up in the @Mapper annotated class.

Co-authored-by: Ben Zegveld <Ben.Zegveld@gmail.com>
2021-10-31 16:46:35 +01:00
Henning Pöttker
e32fc8c283 #2351 NullValueMappingStrategy for Maps and Iterables
With two new parameters for Mapper and MapperConfig, it is now possible to override the nullValueMappingStrategy specifically for MapMapping and IterableMapping.
2021-10-30 13:36:26 +02:00
Filip Hrisafov
80d26a1a9c
#148, #1386, #2593 Only import top level classes
Instead of importing all classes, inner classes will be used through their top level classes only.
This also fixes the problem in #2593 since inner classes are no longer imported but used through their top classes
2021-10-25 08:22:26 +02:00
Filip Hrisafov
564455ee45 #2596 Record components should have the highest priority for read accessors 2021-10-25 08:21:18 +02:00
Filip Hrisafov
935c03e822 #2614 Do not use FQN when mapping Stream to Array 2021-10-25 08:20:59 +02:00
Filip Hrisafov
e86c0faf04 #2611 Scope org.eclipse.tycho:tycho-compiler-jdt under test
Since the removal of the Eclipse Specific compiler workarounds in c2e803403027f3fae92bd15b0ba50ab7df5063e6
the org.eclipse.tycho:tycho-compiler-jdt dependency is no longer needed in the compile code, we only need it for tests
2021-10-24 12:50:49 +02:00
Zegveld
5df6b7a75b
#131, #2438, #366 Add support for Type-Refinement (Downcast) Mapping (#2512)
Add new `@SubclassMapping` for creating Downcast mapping.
When a parent mapping method is annotated with `@SubclassMapping` 
it will now generate an instanceof check inside the parent mapping 
and generate the subclass mappings if they are not manually defined. 

There is also `SubclassExhaustiveStrategy` for controlling what MapStruct should do in case the target type is abstract and there is no suitable way to create it.
2021-10-19 20:44:25 +02:00
valery1707
f167e7a20c Fix typo in JavaDoc 2021-10-16 21:01:20 +02:00
Filip Hrisafov
8b84f5b7d7 #2591 Update dependencies so tests run on Java 18
Update GitHub Actions for tests to run on Java 11, 13, 16, 17 and 18-ea
2021-09-21 22:17:24 +02:00
Filip Hrisafov
b59a23965a #2554 Records should not treat collections as alternative target accessors 2021-09-19 11:42:33 +02:00
Filip Hrisafov
2c23b935db #2541 fix incorrect name for TypeVar with ElementType.TYPE_USE for javac-with-errorprone 2021-09-19 11:41:57 +02:00
Yusuf Kemal Özcan
f0a13bb306 #2555 Add unmappedSourcePolicy annotation processor argument 2021-09-07 22:12:01 +02:00
Tobias Meggendorfer
9057d68cd2
Use DefaultLocale for more stable Issue2544MapperTest (#2569) 2021-08-31 21:45:25 +02:00
Tobias Meggendorfer
9ed4e389f8 #2560 Ignore source properties if ignoreByDefault = true 2021-08-30 21:36:55 +02:00
Daniel Franco
7064e0bc97
Update maven wrapper version to 3.8.2 (#2557) 2021-08-23 16:19:02 +02:00
Adam Szatyin
c52ff812aa
#2552 Add built in conversion between URL and String 2021-08-17 19:21:07 +02:00
Bas Claessen
eb12c485ee
#2515 add ambiguous constructors to ambiguous constructor error message 2021-08-14 09:07:22 +02:00
Bas Claessen
06c416043c
#2515 add ambiguous constructors to ambiguous constructor error message 2021-08-14 09:06:54 +02:00
Henning Pöttker
0d8729767b
Remove remaining references to Hickory (#2511) 2021-08-14 08:38:36 +02:00
Zegveld
c1fa9bd0bd
#2537 Fix incorrect unmapped source property when only defined in Mapping#target 2021-08-14 08:37:20 +02:00
Zegveld
8ad55b164f
#2544: fix missing helper methods for ReverseConversion 2021-08-11 11:35:45 +02:00
Zegveld
196528e578
#2530: fix missing supporting fields for ReverseConversion 2021-08-11 06:49:05 +02:00
Amogh
e6e9b6ce92
#2525 add available transformations to CaseEnumTransformationStrategy exception 2021-07-22 10:08:54 +02:00
Filip Hrisafov
8c554b9556 Change reference from Google Group to GitHub Discussions in reference guide 2021-07-18 15:55:17 +02:00
Filip Hrisafov
43dfd92e05 [maven-release-plugin] prepare for next development iteration 2021-07-18 15:15:44 +02:00
Filip Hrisafov
a91b93f357 [maven-release-plugin] prepare release 1.5.0.Beta1 2021-07-18 15:15:44 +02:00
Sjaak Derksen
a95d1c59c3
#2505 deepclone generates enum mapping method (#2507) 2021-07-03 15:28:10 +02:00
Filip Hrisafov
38744d9f73 Add users that have contributed to 1.5 to the copyright.txt 2021-06-27 18:43:13 +02:00
Christian Kosmowski
985ca2fe64 #1075 Support for Mapping from Map<String, ???> to Bean
Co-authored-by: Filip Hrisafov <filip.hrisafov@gmail.com>
2021-06-27 07:34:37 +02:00
Filip Hrisafov
fb9c7a3ded #2491 Do not use types not part of java.base in MapStruct processor
MapStruct should not use types that are outside of java.base.
This makes sure that no additional dependencies (such as jaxb-api) are needed on the annotation processor path
2021-06-27 07:34:14 +02:00
Filip Hrisafov
c5c292f602 #2501 Add test case 2021-06-27 07:33:45 +02:00
Andrew
1bf698785c
Fix typo in Named.java (#2500) 2021-06-24 19:19:02 +02:00
chaos
4c338fa1db fix(pom): fix gradle repo url 404
original url is 404 replace with new url
2021-06-23 13:02:14 +02:00
Tobias Meggendorfer
5d8fcfa033 #2481 Report ignored source properties which are missing 2021-06-21 19:50:58 +02:00
Filip Hrisafov
845d83e9d5 #2439 Do not throw NPE getting accessors for null typeElement
Provide better error message if the source type has no read properties
2021-06-20 08:55:57 +02:00
Filip Hrisafov
934a47323a #2478 Make sure that forged methods do not generate duplicate method parameters 2021-06-19 15:55:41 +02:00
Sjaak Derksen
7f38efad4d
#2463 Selection stops when method type-args are flipped (#2487) 2021-06-19 13:56:26 +02:00
Filip Hrisafov
55c62ab43f #2108 Make sure Javadoc can be generated with Java 11
Remove the org.jboss.apiviz.APIviz doclet since it is no longer compatible with Java 11.
Add new group in the Javadoc for the MapStruct Processor SPI
Fix Javadoc warnings
2021-06-19 11:50:48 +02:00
Filip Hrisafov
046077f701 #2483: Update Asciidoctor to latest versions 2021-06-19 11:49:38 +02:00
Filip Hrisafov
08016d9ef2
#2446 Use DefaultLocale and DefaultTimeZone from JUnit Pioneer
Configure the JUnit Platform to run the processor tests in parallel by running different test classes in concurrent threads
2021-06-12 10:16:40 +02:00
Filip Hrisafov
9ce9d4fb3a #2375 Add records cross module integration test 2021-06-12 09:23:36 +02:00
Filip Hrisafov
857f87276f #2466 Update dependencies so tests run on Java 16+
Update GitHub Actions for tests to run on Java 11, 13, 16 and 17-ea.
Update Lombok so tests can run on 16+
Add jaxb-runtime dependency to the maven-jaxb2-plugin see https://github.com/highsource/maven-jaxb2-plugin/issues/148
Disable cdi integration test on Java 16+ until we find a solution for them
2021-06-12 09:20:33 +02:00
Filip Hrisafov
70ea65f7aa #2437 Do not visit the same type element twice when retrieving methods
When using the diamond inheritance a TypeElement might be visited twice.
This is however, incorrect. We need to visit a TypeElement exactly once.
2021-05-16 19:08:45 +02:00
Ewald volkert
a6ac4f3fd6 #2329 use fields for custom date formats with DateTimeFormatter in order to optimise its usage
* GetDateTimeFormatterField
** a FieldReference that creates DateTimeFormatters
   for given dateFormat as mapper fields
** variableName is created using given dateFormat

* AbstractJavaTimeToStringConversion
  provides GetDateTimeFormatterField as required helper field
  using DateTimeFormatter instances provided as mapper fields
  by GetDateTimeFormatterField

* ConversionProvider
  might provide supporting fields directly

* Refactoring
  moved/renamed BuiltInFieldReference, BuiltInConstuctorFragment to
package model/common

* MappingBuilderContext provides access to mapper support fields
  (that are independent of mapper methods)

* MappingResolverImpl / MapperCreationProcessor
  process supporting fields provided by ConversionProvider

* HelperMethod
** extended to supply additional template parameters to
   be more flexible in freemarker templates
** extended to support mapper field reference / constructor fragment

* SupportingMappingMethod
** provide templateParameters to freemarker
** hashCode/equals base on name property instead of template name,
   as we use one specific template multiple times with different
   parameters generating multiple methods
** #getSafeField extracted to SupportingField

* SupportingField
** removed hashCode/equals based on template name,
   as we use one specific template multiple times with different
   parameters generating multiple methods
   (superclass equals/hashcode is fine for that)
** added support for template parameters to be more flexible when
  compiling templates

* Tests to verify DateTimeFormatter instance field creation
2021-05-16 13:22:56 +02:00
Lukas Lazar
cc1562c5ad #2132 Add unmappedTargetPolicy to @BeanMapping 2021-05-15 18:01:22 +02:00
Filip Hrisafov
4576103752 #2445 Improve error reporting when EnumTransformationStrategy throws an error during transformation 2021-05-15 13:04:15 +02:00
João Paulo Bassinello
fdf3dcc8ef #2445 Support for case changing enum transformation strategy
Available case transformations: upper, lower, capital
2021-05-15 13:04:15 +02:00
dependabot[bot]
5c22eee6c3 Bump commons-io from 2.6 to 2.7 in /parent
Bumps commons-io from 2.6 to 2.7.

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-01 13:41:46 +02:00
jason.bodnar@blackbaud.com
0cb053df8d #2391 Add implicit conversion between UUID <-> String 2021-05-01 13:28:03 +02:00
Filip Hrisafov
627be53088 Migrate mapstruct core tests to JUnit Jupiter 2021-04-25 13:05:26 +02:00
Filip Hrisafov
2d66f08ee5 Migrate process tests to use new JUnit Jupiter Infrastructure
Update test annotations to be JUnit Jupiter compatible

Replace all Test annotations from tests that are run with the AnnotationProcessorTestRunner with ProcessorTest.
Replace JUnit 4 Test#expected with assertThatThrownBy from AssertJ.
Replace Rule for GeneratedSource with RegisterExtension.
Fix some tests that were not reverting the changes to the default Locale and TimeZone.
Replace usage of org.junit.Assert with equivalent from org.junit.jupiter.api.Assertions or AssertJ.
2021-04-25 13:05:26 +02:00
Filip Hrisafov
5bbd1a78ea Migrate the processor test infrastructure from JUnit 4 to JUnit Jupiter
With JUnit Jupiter it is still not possible to set the ClassLoader for loading the test class.
However, since 5.8 M1 there is a way to hook into the launcher discovery process and change the Current Thread ContextClassLoader which would load the classes with our customer ClassLoader.
Once JUnit Jupiter 201 is resolved we can simplify this.

The CompilationCache is stored in the GlobalCache with the CompilationRequest as key.
This means that even when methods are not executed in some particular order if they have same WithClasses then they would reuse the cache.
2021-04-25 13:05:26 +02:00
Filip Hrisafov
51cdbd67e3 #2051, #2084 Add new @Condition annotation for custom presence check methods 2021-04-25 12:09:23 +02:00
Filip Hrisafov
a2e1404b93 Refactor presence checks to object in order to simplify the conditional mapping 2021-04-25 12:09:23 +02:00
Filip Hrisafov
1c8fff1475 #2423 Use SetterWrapperForCollectionsAndMapsWithNullCheck if the source has a presence check method 2021-04-24 22:01:09 +02:00
Filip Hrisafov
903e6f3f44 #597 Add String <-> StringBuilder conversion in the documentation 2021-04-24 16:47:27 +02:00
Filip Hrisafov
2be536bb65 #2303 Generated code should use iteration order preserving LinkedHash(Map|Set) instead of Hash(Map|Set) 2021-04-24 14:19:01 +02:00
Filip Hrisafov
5f1b3d7862 #2402 Always add source parameter name when constructing the source references for target this 2021-04-23 07:58:24 +02:00
Filip Hrisafov
c9199b7068 #2393 Use includeModel when generating GeneratedType
With this we make sure that the implementation type will have a correct import in case of a clash with another mapper named the same
2021-04-16 08:41:53 +02:00
Silvère Marie
85d3b310f7 Fix method naming 2021-03-30 08:45:17 +02:00
Sjaak Derksen
1187e357c1
#2239 matching generics (#2320) 2021-03-28 17:34:59 +02:00
Filip Hrisafov
e7f6813d9a #2356 Implicitly ignore reverse inherited mappings that do not have read and write methods 2021-03-27 16:12:44 +01:00
Filip Hrisafov
1964c809d8 Fix typo in missing code formatting in documentation
Closes #2385
2021-03-16 20:24:51 +01:00
Filip Hrisafov
197dd4327a #2339 Polish PR #2362
Use MappingEntry for defaultTarget and nullTarget in ValueMappingMethod to simplify certain things
2021-03-15 00:32:02 +01:00
jude.niroshan11@gmail.com
c4135e68ed #2339 Support throwing an exception as an Enum Mapping option 2021-03-15 00:32:01 +01:00
Jude Niroshan
228660c74f
#2366 Update documentation in regards to Java Module System 2021-03-07 14:11:45 +01:00
Jeroen van Wilgenburg
d9fdd86b94 #2368 fix order of target parameter in tests (and removed some spaces) 2021-03-01 20:58:13 +01:00
Jeroen van Wilgenburg
d5703d3ee8 #2368 fix order of target parameter in documentation 2021-03-01 20:58:13 +01:00
Filip Hrisafov
85af901ea7 #2350 Generate core string to enum mapping when AnyRemaining or AnyUnmapped is not used 2021-02-07 11:21:59 +01:00
Filip Hrisafov
07f5189a72 #2347 Do not generate mapper implementation for private mappers
Provide a compiler error message instead of generating code that will not compile
2021-02-07 11:03:04 +01:00
Filip Hrisafov
f4b62ded89 #2352 Add source element type for Iterable mappings
When the Iterable type we are mapping is not generic
(i.e. it is a custom type extending an Iterable) then the source element type
which is included in the loop was not imported.
2021-02-07 10:37:49 +01:00
Filip Hrisafov
630a8da904 Fix a typo in the Mapper#componentModel 2021-02-06 16:44:07 +01:00
Filip Hrisafov
b643061b57 #2277 Add tests with fixtures with testing the generated source code 2021-02-06 16:31:18 +01:00
dmngb
c59ca79e7f
#2277 default component model: mapper reference use singleton INSTANCE if it exists (#2280)
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>
2021-02-06 16:10:32 +01:00
Filip Hrisafov
aeadf8cb77
Update readme with latest released 1.4.2.Final release 2021-01-31 14:52:11 +01:00
Filip Hrisafov
08af258533 #2346 Update documentation and readme about MapStruct and Gradle
Remove obsolete net.ltgt.apt
Use com.diffplug.eclipse.apt for Eclipse
IntelliJ works transparently
2021-01-31 09:26:58 +01:00
Filip Hrisafov
0d8bbacc53 #2250, #2324 Do not throw error when qualifier is missing on iterable mapping
With this change we are relaxing the error handling when qualifiers are used in `@Mapping`
and we allow defining qualifiers for collections / array mapping to mean the same as if it was defined on `@IterableMapping`
i.e. apply the qualifier on the element mapping
2021-01-30 09:43:16 +01:00
Sjaak Derksen
8478a5455b
#2278 inherited property ignored due to ignore on nested level (#2332)
Co-authored-by: sjaakd <sjaakderksen@zonnet.nl>
2021-01-23 09:15:46 +01:00
Filip Hrisafov
dfc7528096 Small fixes for Java 16
* Upgrade japicmp-maven-plugin to 0.15.2
* Do not use deprecated for removal Long constructor
* Update Spring to 5.3.3
* Upgrade Lombok to 1.18.16 + add lombok-mapstruct-binding
2021-01-22 08:33:03 +01:00
Tomas Poledny
4223e3ab81 #2255 Add constants for componentModel 2021-01-17 15:13:42 +01:00
Filip Hrisafov
700293f089 #2301 Implicitly ignore forward inherited mappings from different method types 2021-01-01 21:30:25 +01:00
Filip Hrisafov
f84f756a4c #2293 Use MapperConfig instead of MappingConfig in the documentation 2021-01-01 21:29:48 +01:00
Michael Düsterhus
e73dd1b485 Update chapter-2-set-up.asciidoc
See official maven doc on this: https://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html
Otherwise for example intellij doesn't recognize the compiler options on maven import
2020-12-15 19:32:19 +01:00
Filip Hrisafov
84c3bda5a2
#2274, #2023 Fix problems with property mapping using source parameters
Fixes problems when property mapping is using source parameter and has default value / expression or is doing an update
2020-11-22 13:04:26 +01:00
Nikolas Charalambidis
6daea86a1b
Add Lombok subsection in the documentation (#2266) 2020-11-11 22:28:53 +01:00
Filip Hrisafov
6df9243d92 #2253 remove unmapped source properties when source parameter is directly mapped 2020-11-08 09:57:10 +01:00
Filip Hrisafov
75f963adf6 #2263 Fix IndexOutOfBoundsException when resolving TypeVar to a Type 2020-11-08 09:56:15 +01:00
Nikolas Charalambidis
8f9df5b69b
#2258 Fixes vague description of @Default and @ConstructorProperties annotations 2020-11-04 21:39:06 +01:00
Filip Hrisafov
749ded96c1 #2251 Fix incorrect code generated for constructor mapping from implicit source parameter matching 2020-11-01 14:59:44 +01:00
Filip Hrisafov
3256abb79c #2244 Mark mapstruct-processor jar as Spring-Boot-Jar-Type: annotation-processor
Doing this would make sure that starting from Spring Boot 2.4 the mapstruct-processor will not be included in the fat jar produced by the Spring Boot maven plugin if people have it as a maven provided dependency.

This is an alternative if people are not using the maven-compiler-plugin annotationProcessorPaths
2020-10-28 08:54:01 +01:00
Filip Hrisafov
85890dd442 #2245 Local variable should be created when using default value 2020-10-25 14:42:48 +01:00
Kemal Ozcan
e67daa3710 mapstruct#597 Built-In conversion between String and StringBuilder 2020-10-24 17:33:53 +02:00
Saheb Preet Singh
26f62b7ef0 #607 Mapping Iterable<?> object to an object instead of collection 2020-10-21 21:20:46 +02:00
Sjaak Derksen
c2e8034030
861 remove compiler specific workarounds (#2227) 2020-10-21 20:02:28 +02:00
Filip Hrisafov
74d06fea5d #2233 Allow generic of generics in types when matching
e.g. method signature such as
<T> T fromOptional(Optional<T> optional)

when T resolves to another generic class such as Collection<String>
2020-10-21 17:00:05 +02:00
Filip Hrisafov
6102d0cc8e #2236 Different nested target mappings should generate different intermediate methods
Make sure that MappingReferences are taken into consideration when comparing whether 2 mapping methods are equal.
This makes sure that when using nested target mappings that have the same property mappings, but different mappings 2 distinct methods will be created
2020-10-18 22:31:08 +02:00
Filip Hrisafov
50aa9cdbdc Use junit version defined in parent in integration tests 2020-10-17 12:30:43 +02:00
dependabot[bot]
4ddfd2ff51 Bump junit from 4.12 to 4.13.1 in /parent
Bumps [junit](https://github.com/junit-team/junit4) from 4.12 to 4.13.1.
- [Release notes](https://github.com/junit-team/junit4/releases)
- [Changelog](https://github.com/junit-team/junit4/blob/main/doc/ReleaseNotes4.12.md)
- [Commits](https://github.com/junit-team/junit4/compare/r4.12...r4.13.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-14 15:46:19 +02:00
Filip Hrisafov
0e902d6412 Update versions in readme to 1.4.1.Final 2020-10-11 10:00:24 +02:00
Filip Hrisafov
58dbaee472 [maven-release-plugin] prepare for next development iteration 2020-10-11 09:35:30 +02:00
Filip Hrisafov
d8f22f8311 [maven-release-plugin] prepare release 1.4.1.Final 2020-10-11 09:35:30 +02:00
Filip Hrisafov
2b95e07d8e Turn of Maven connection pooling to avoid connection issues on CI
The problem and solution are explained in https://github.com/actions/virtual-environments/issues/1499#issuecomment-689467080
2020-10-10 10:22:43 +02:00
Filip Hrisafov
53a5c34ed6 #2206, #2214, #2220: Source property should be correctly determined when only target is defined
When having multiple source properties and only target is defined then the same rules should be applied as if there was no mapping:

* First we check for a matching property in any of the source type
* Second we check if the parameter name matches
2020-10-10 09:44:01 +02:00
Filip Hrisafov
a5f49e591e #2221: Fix configuration inheritance when there are multiple matching source parameters of the same type 2020-10-10 09:43:30 +02:00
Filip Hrisafov
823b5edd9f #2213: primitive arrays should be directly mapped (we are cloning them anyways)
Additionally fix problem when annotations `ElementType.TYPE_USE` not handled correctly for javac
2020-10-03 16:54:01 +02:00
Filip Hrisafov
233fc6de98 #2215: Avoid NPE in IntelliJ EAP 2020.3
Starting from IntelliJ 2020.3 (Build 203.4203.26) the ProcessingEnvironment is wrapped in a Proxy class by IntelliJ.
MapStruct should gracefully handle that and not throw an NPE.
Additionally, we should do best effort to put the used compiler in the generated annotation info
2020-10-03 16:47:31 +02:00
Jasper Vandemalle
4480e0f367 Fix minor typos 2020-10-03 00:35:28 +02:00
Filip Hrisafov
2d750193d1 Update versions in readme to 1.4.0.Final 2020-09-26 11:45:27 +02:00
Filip Hrisafov
eb5b8bb71e [maven-release-plugin] prepare for next development iteration 2020-09-26 10:20:47 +02:00
Filip Hrisafov
9973b92ccb [maven-release-plugin] prepare release 1.4.0.Final 2020-09-26 10:20:45 +02:00
Filip Hrisafov
060f17e3e2 #2125 Report an error when source parameter could not be determined from target mapping 2020-09-21 07:55:45 +02:00
Filip Hrisafov
e17e744b20 Dependency upgrades
Upgrades:
* Maven Enforcer Plugin to 3.0.0-M3
* Maven Surefire Plugin to 3.0.0-M5
* Maven Checkstyle Plugin to 3.1.1
* Maven Bundle Plugin to 5.1.1
* Jacoco Maven Plugin to 0.8.6
* Checkstyle to 8.36.1
* JUnit Jipiter to 5.7.0
* AssertJ to 3.17.2
* Guava to 29.0-jre

Fix AssertJ breaking changes
Use Java 8 or Apache Commons IO instead of Guava where possible
Update GitHub Actions to use JDK 14 and JDK 15-ea
2020-09-20 11:37:23 +02:00
Filip Hrisafov
52ab22bbd8 #2197 Strip leading underscores and digits when sanitizing identifier name 2020-09-20 09:46:41 +02:00
Sjaak Derksen
427f5023ef
#2195 @Beanmapping#resultType should be used to construct return type also if it's a builder (#2196) 2020-09-06 16:12:01 +02:00
Filip Hrisafov
8b22654abd [maven-release-plugin] prepare for next development iteration 2020-08-30 16:31:45 +02:00
Filip Hrisafov
c962962546 [maven-release-plugin] prepare release 1.4.0.CR1 2020-08-30 16:31:44 +02:00
Sjaak Derksen
e0eb0f6bb8
#2164 parameter matching should be done based on name when source name is absent (#2193) 2020-08-30 12:49:09 +02:00
Filip Hrisafov
7dcbef349d
#2169 Add support for defining a custom unexpected value mapping exception
Expose definition via:

* `@EnumMapping`
* `@Mapper`
* `@MapperConfig`
* `EnumMappingStrategy` SPI

Rename `EnumNamingStrategy` to `EnumMappingStrategy`
2020-08-29 13:53:30 +02:00
Filip Hrisafov
a9451b1159 #2185 Fix StackOverflow error when recursive use of mapper in Mapper#uses 2020-08-29 11:56:02 +02:00
Filip Hrisafov
c1feafef4c
#2177 Mapping into a generic class / record with a typed constructor argument should work 2020-08-29 11:22:18 +02:00
Filip Hrisafov
3ce9786cf6
#2174 Forged methods should inherit all thrown exceptions from their property mappings 2020-08-29 08:59:20 +02:00
Makoto Oda
99a1fd609c
Documentation: typo? (#2186) 2020-08-25 20:38:19 +02:00
Makoto Oda
18a5f1bdc0
Documentation: Extra phrase inserted? (#2187) 2020-08-25 20:37:02 +02:00
Makoto Oda
e6279d10c7
Is 'r' missing? (#2188) 2020-08-25 20:34:02 +02:00
Filip Hrisafov
ed16d62a91 #2170 Make sure that an import is created for constructor mapping defined variables 2020-08-02 09:36:22 +02:00
Filip Hrisafov
609824037b #2167 Add missing @since 1.4 to new interfaces, classes and methods 2020-08-01 11:43:46 +02:00
Sjaak Derksen
2e2c20fed7
#2161 use short names instead of FQN's in error messages (#2166) 2020-07-24 23:19:47 +02:00
Filip Hrisafov
ef4bfc9aad [maven-release-plugin] prepare for next development iteration 2020-07-19 18:10:13 +02:00
Filip Hrisafov
1d223284c2 [maven-release-plugin] prepare release 1.4.0.Beta3 2020-07-19 18:10:12 +02:00
Filip Hrisafov
0495cb7fa7 #2149 Do not allow using BeanMapping(ignoreByDefault = true) in combination with Mapping(target = ".")
This fixes an ArrayIndexOutOfBoundsException when they were used together
2020-07-19 16:19:52 +02:00
Filip Hrisafov
28017e2b0c Add test case for demonstrating how the ignoreByDefault can be overridden from the base configuration 2020-07-19 16:19:52 +02:00
Sjaak Derksen
36349c49e9
#2156 ambiguous mapping message: location and limit # candidates (#2162) 2020-07-19 15:40:30 +02:00
Filip Hrisafov
cb432fa61b
#2150 Change the rules for how a constructor for mapping is picked
New rules:

1. Constructor annotated with @Default (from any package) has highest precedence
2. If there is a single public constructor then it would be used to construct the object
3. If a parameterless constructor exists then it would be used to construct the object, and the other constructors will be ignored
2020-07-18 18:53:32 +02:00
Filip Hrisafov
6aa39ff428 #2142: Strip leading underscore when sanitizing identifier name 2020-07-18 11:35:25 +02:00
Sjaak Derksen
2a849dca12 #2145 fixing 2 step mapping methods (refactoring) (#2146) 2020-07-18 01:12:21 +02:00
Sjaak Derksen
74f281fa3e #2135 improved messages for not able to select qualified method (#2141)
* #2135 improved messages for not able to select qualified method
2020-07-18 01:12:15 +02:00
Sjaak Derksen
c0d88f86bf #2139 reproducer (#2140)
* #2139 reproducer

* #2139 solution

* #2139 license
2020-07-18 01:12:11 +02:00
Filip Hrisafov
2fede3583d [maven-release-plugin] prepare for next development iteration 2020-07-18 01:12:05 +02:00
Filip Hrisafov
fc4f65ddb6 [maven-release-plugin] prepare release 1.4.0.Beta2 2020-07-05 23:11:41 +02:00
Sjaak Derksen
12ac348609
#2136 performance improvement 2 step mappings (#2138) 2020-07-04 22:06:30 +02:00
Sjaak Derksen
1ce282362c
#2101 inherited properties need to be analysed against redefined properties when inheriting mappings (#2103) 2020-07-04 21:50:20 +02:00
Sjaak Derksen
971abc48c7
#2122 fix for 2 step mapping and generics (#2129) 2020-07-04 18:49:33 +02:00
Sjaak Derksen
81a88bdb6c
#2133 @BeanMapping#resultType should not be applied to forged methods (#2134)
* #2133 reproducer

* #2133 solution
2020-07-04 18:20:09 +02:00
Filip Hrisafov
082704cc55 #2131 Add extra test case 2020-07-04 17:27:55 +02:00
SahinSarkar
13df6a21bc Fixed typo in documentation 2020-07-04 16:55:24 +02:00
Filip Hrisafov
92b4316abd #2117 Add extra test case 2020-06-21 23:47:02 +02:00
Filip Hrisafov
bdc58b9602 #2124 Add extra test case 2020-06-21 23:24:56 +02:00
Filip Hrisafov
ef3cbc1b36 #2121 Add extra test case 2020-06-21 23:19:23 +02:00
Sjaak Derksen
29b82e772c
#2111 extra tests (#2119) 2020-06-14 21:04:31 +02:00
Filip Hrisafov
da37d40152
#2109 Generate correct array assignment for constructor parameter mapping 2020-06-07 16:45:32 +02:00
Filip Hrisafov
d87d75a7a8 [maven-release-plugin] prepare for next development iteration 2020-06-01 13:42:32 +02:00
Filip Hrisafov
72ce5f3bd2 [maven-release-plugin] prepare release 1.4.0.Beta1 2020-06-01 13:42:32 +02:00
Filip Hrisafov
fc5e1ffe6b Upgrade to latest 1.6.2 asciidoc and fix incorrect closing documentation tag 2020-05-30 15:34:54 +02:00
Filip Hrisafov
850a55cd5d #695 Check for direct assignment for iterable, stream or map types should be done on their type parameters instead of the types themselves 2020-05-30 14:27:15 +02:00
Filip Hrisafov
c23592a7fe
Add EnumNamingStrategy SPI (#2100)
Add a new EnumNamingStrategy SPI which can be used for customising the way enums are matched by name.
It is similar to the AccessorNamingStrategy such that it allows implementors to provide a custom way of defining a property.

Related to #796, #1220, #1789 and #1667
2020-05-25 21:31:29 +02:00
Filip Hrisafov
7b5a54971f
Add EnumTransformationStrategy SPI (#2089)
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.
2020-05-18 07:17:30 +02:00
Filip Hrisafov
b5fe96c9da Add myself as developer 2020-05-17 18:46:33 +02:00
Filip Hrisafov
73a79cf009 #1857 Use flatten-maven-plugin to remove test dependencies from released pom
For some reason when using annotationProcessorPaths IntelliJ includes the provided and test scoped dependencies on the annotation processor paths.
With this change there would be no test dependencies that IntelliJ can add.
2020-05-17 18:45:05 +02:00
Gunnar Morling
f7c1182ae6
Updating my developer URL 2020-05-17 13:27:32 +02:00
Filip Hrisafov
42e0ec395b Add dedicated action for Java EA builds and update main CI to use only 11, 13 and 14 2020-05-17 12:17:36 +02:00
Filip Hrisafov
2b2299a730 #73 Add support for using constructor arguments when instantiating mapping targets
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
2020-04-26 12:44:41 +02:00
Filip Hrisafov
d6ff5204d7 Accessor#getSimpleName should return a String 2020-04-26 12:44:41 +02:00
Sjaak Derksen
7c62aec281
#2077 nullpointer due to no-getter source (#2078) 2020-04-25 17:01:22 +02:00
Filip Hrisafov
3bffe96983 #1159: Do not fail loading AnnotationProcessorContext if loading AstModifyingAnnotationProcessor fails 2020-04-13 17:40:47 +02:00
Filip Hrisafov
c58f80cc5f #2069 Refactor target reference to report errors during bean mapping instead of creation of the target reference
With this we can more easily go in the direction of using constructor to map into target beans.
2020-04-13 13:20:09 +02:00
Filip Hrisafov
1bbc4e1ca8 Use expected.getMessageRegex when no message for the Diagnostic descriptor has been defined 2020-04-12 12:26:07 +02:00
Filip Hrisafov
6797afb647 Use exact message for Diagnostic test messages assertions 2020-04-12 09:55:44 +02:00
Filip Hrisafov
a845197b0b #2056: Handle null TypeMirror in uses and import gracefully
Due to a bug in javac (JDK-8229535) for an annotation with Class values, instead of returning a TypeMirror with TypeKind#ERROR the compiler returns the string "<error>". Eclipse doesn't have this problem currently.
2020-04-10 11:20:20 +02:00
Filip Hrisafov
c410379f83 #1553: Update tycho-compiler-jdt to latest 1.6.0 version
Disable one test in GenericsHierarchyTest for Eclipse on Java 8 due to a bug in the Tycho compiler.
Disable freeBuilder integration test for Eclipse since there are some problems in the second round of annotation processing (no ModelElementProcessor(s) are found)
2020-04-10 09:33:09 +02:00
Filip Hrisafov
853ff7f74f #2060: MapStruct should work properly on the module path 2020-04-05 16:37:51 +02:00
Filip Hrisafov
4f76208c62 #2021 Generate compilable code when Decorator is nested within the Mapper
We need to treat the import of the decoratorType specially when it is nested.
Calling addIfImportRequired is not the most correct approach since it would
lead to checking if the type is to be imported and that would be false
since the Decorator is a nested class within the Mapper.
However, when generating the Decorator this is not needed, because the Decorator is a top level class itself

In a nutshell creating the Decorator should have its own ProcessorContext, but it doesn't
2020-04-05 14:09:23 +02:00
Filip Hrisafov
b7d5e557c1 Checkstyle max line length should be 120 2020-04-05 09:29:00 +02:00
Pawel Radzinski
bbd68baf64
Update chapter-10-advanced-mapping-options.asciidoc (#2050)
Correct some typos and punctuation here and there.
2020-03-30 21:11:07 +02:00
Filip Hrisafov
f8a3924005 Use fix version for maven-processor-plugin
Using the latest (4.0-beta1) does not work on Java 8 since it is compiled with Java 9
2020-03-07 16:44:19 +01:00
Filip Hrisafov
63c2edd333 Reset locale and time zone in every test 2020-03-07 16:44:19 +01:00
Filip Hrisafov
551c104295 #2019 Setup GitHub Actions
Add Maven Wrapper for using in GitHub Actions
Remove Travis
2020-03-07 16:44:19 +01:00
Filip Hrisafov
fe91c6d523 Disable Checkstyle for Target for #2018 test 2020-02-23 19:06:46 +01:00
Filip Hrisafov
b9f86fe6ac #2018 Add test case with properties with underscore verifying that it is working as expected 2020-02-23 17:33:32 +01:00
Filip Hrisafov
f5771c4177 #2014 Add support for mapping from Java 14 records 2020-02-23 13:34:08 +01:00
Sean C. Sullivan
273487f152 maven-compiler-plugin 3.8.1 2020-02-18 07:16:31 +01:00
Tim J. Baumann
a6b3cc364a Fix Javadoc of resolveViaMethodAndConversion
and fix some smaller Javadoc typos.
2020-02-07 17:38:59 +01:00
Robin Clarke
015468b461 Updated versions on readme.md to 1.3.1.Final 2020-02-07 17:37:06 +01:00
Filip Hrisafov
c64e03468e Fix Checkstyle error 2020-02-07 17:35:51 +01:00
Filip Hrisafov
f382903bc6
Add proper attribution for the code for generating the sourceTargetVersion for other JRE 2020-02-04 13:05:53 +01:00
Filip Hrisafov
02a113b2d4
#1308 Switch to JUnit Jupiter and do not use Toolchains for the integration tests (#2013)
The CI should be setup to run on different Java versions, for which the integration tests are going to be run
2020-02-03 21:56:48 +01:00
Filip Hrisafov
95ceba1a1e #2016 Update Checkstyle to 8.29
Adapt checkstyle configuration with new changes:
* Move cacheFile to Checker module
* Move LineLength to Checker module
* Use SuppressWithPlainTextCommentFilter
2020-02-02 14:33:45 +01:00
Sjaak Derksen
58da2d293f
#695 user control over mapping means (direct, method, conversion, 2step) 2020-02-02 10:05:26 +01:00
Sjaak Derksen
2d3761051a
#2011 Introduce gem as replacement of hickory:prism (#2007) 2020-01-27 20:16:04 +01:00
sjaakd
6b49c838eb #1998 simplify usage of inheritance of annotation fields 2020-01-25 09:13:50 +01:00
sjaakd
b84526b24a #1998 preparation move classes to new names 2 2020-01-25 09:13:50 +01:00
sjaakd
2b36c220a3 #1998 preparation move classes to new names 1 2020-01-25 09:13:50 +01:00
Filip Hrisafov
d056570267 #2001 Avoid NPE when checking whether import type element is nested
When the typeToAdd is an array then TypeElement is null and ComponentType is the one that would be imported
2020-01-24 22:02:51 +01:00
Marcel Overdijk
327730127b Updated docs to add compilerArgs instead of replacing them.
When configuring MapStruct compilerArgs *add* them, no *replace*
2020-01-24 21:59:46 +01:00
Sjaak Derksen
076f3ba839
#1995 follow up, small typo 2020-01-10 20:16:25 +01:00
Sjaak Derksen
57cfd35afc
#1995 and mapstruct/mapstruct.org#101 nesting calling custom method (#1999)
Co-authored-by: coffman21 <fire2low@gmail.com>
2020-01-09 20:59:36 +01:00
Sjaak Derksen
c153c8bf5a
#1983 javadoc and doc on @ignore in @InheritInverseConfituration (#1986) 2019-12-23 20:41:38 +01:00
fml2
84062bf78f docs: Fix typo in the builder section 2019-12-09 21:01:19 +01:00
ttzn
779eb1bd47 #1420 Add support for Gradle incremental annotation processing (#1971)
* Add relevant file in META-INF
* Add integration test with Gradle test kit dependencies
* Test with Gradle 5 and Gradle 6
2019-12-08 19:55:16 +01:00
Sjaak Derksen
ee794d042c
#807 meta annotations and duck typing (#1979) 2019-12-07 22:20:11 +01:00
Sjaak Derksen
071e5dc6b2
#1966 extra unit test (#1967) 2019-11-10 20:14:33 +01:00
Andrei Arlou
b26cd4e0cb
#1953 Fix TODO items for: integrationtest-java8Test, integrationtest-lombokBuilderTest, processor-nullvaluemappingTest (#1955) 2019-10-26 22:24:59 +03:00
Andrei Arlou
efea2fb662
#1951 Use Map.computeIfAbsent in NestedTargetPropertyMappingHolder (#1952) 2019-10-20 22:11:17 +03:00
Andrei Arlou
74a2e358e8 #1946 Simplify conditions in classes: Parameter, SelectionParameters, MethodReference, PropertyMapping 2019-10-20 21:01:58 +02:00
Andrei Arlou
e8a7832d5b
#1948 Fix minor warnings with using collection in package model and class util/workarounds/EclipseAsMemberOfWorkaround (#1949) 2019-10-20 14:16:26 +03:00
Andrei Arlou
fe37b01c65
#1944 Remove unused constants in JavaStreamConstants (#1945) 2019-10-20 14:13:38 +03:00
Sjaak Derksen
5fbc86d92f
#1788 allowing enum / not enum by removing checks (#1939) 2019-10-08 21:06:47 +02:00
Sjaak Derksen
507ec1b384
#1557 & #1936 String-to-enum and enum-to-String (#1938)
* #1557 making enum-to-string and string-to-enum

* #1936 <ANY_REMAINING> and <ANY_UNMAPPED> not ignored when inverting
2019-10-07 20:30:20 +02:00
Filip Hrisafov
44ae27d7ca #1881 Use ReportingPolicy#IGNORE for unmappedSourcePolicy when mapping references are for forged methods
This aligns with the way the ReportingPolicy is handled for unmappedTargetPolicy when mapping references are for forged methods
2019-10-06 21:05:25 +02:00
Sjaak Derksen
1cb8291fb9
#1933 ignoreByDefault not inherited from config (#1935) 2019-10-05 15:47:25 +02:00
Filip Hrisafov
b3023b3902
#1828 Use update method when nested property of target is populated with multiple nested properties of source (#1931) 2019-09-29 17:21:20 +02:00
Filip Hrisafov
999d428ad8 #1742 Add test case 2019-09-28 19:15:22 +02:00
Andrei Arlou
81cd439343 #1921 Fix minor warnings in testutil 2019-09-26 20:02:53 +02:00
Sjaak Derksen
0d23f09e37
#1918 multiple target this mappings (#1920) 2019-09-23 20:04:56 +02:00
Andrei Arlou
61f941aa80
#166 Add code-examples to Javadoc of org.mapstruct.* annotations (#1876) 2019-09-22 21:25:57 +03:00
Andrei Arlou
70de843bea
#1911 Change return type MapperConfiguration.getBuilderPrism from Optional<BuilderPrism> to BuilderPrism (#1912) 2019-09-22 20:41:35 +03:00
Sjaak Derksen
ade4f4d7e2
#1821 nullpointer due to @BeanMapping via inheritance (#1822) 2019-09-22 19:25:43 +02:00
Filip Hrisafov
1c4bbba442 #1799 Fluent setters starting with set should work properly 2019-09-22 19:09:04 +02:00
Dainius Figoras
88a8669642 #1406 targeting . as current object 2019-09-22 19:08:05 +02:00
Filip Hrisafov
f0a00eb0d5
Add Dekel Pilli to copyright.txt 2019-09-22 15:07:04 +02:00
dekelpilli
f84f6501c8 #1851 Do not allow using qualifiedBy and qualifiedByName with expression in Mapping 2019-09-22 13:53:19 +02:00
Andrei Arlou
55fe94a93e
#1914 Remove unused method Type.isAnnotatedWith (#1915) 2019-09-22 10:50:38 +03:00
Andrei Arlou
f4c9313972
#1791 Support for conversion between java.time.LocalDateTime and javax.xml.datatype.XMLGregorianCalendar (#1894) 2019-09-21 22:27:45 +03:00
Filip Hrisafov
fcdf852a17 #1904 Do not include private methods when getting enclosed executable elements 2019-09-21 21:10:58 +02:00
Filip Hrisafov
e92e3b45c6 #1904 Create compilation error if a mapper could not be created due to a TypeHierarchyErroneousException 2019-09-21 21:10:58 +02:00
Andrei Arlou
750ce48023 #1792 Annotation processor option for default injection strategy 2019-09-18 19:51:36 +02:00
Filip Hrisafov
d018aed251
#1790 Use mapperPrism.values.nullValuePropertyMappingStrategy when retrieving NullValuePropertyMappingStrategy 2019-09-18 13:09:40 +02:00
Andrei Arlou
447bb00f89
#1773 Update documentation: componentModel=jsr330 with @DecoratedWith not longer experimental (#1907) 2019-09-18 07:18:05 +03:00
Sjaak Derksen
7e0327767f
#1801 Using constructor as builderCreationMethod in custom builder (#1905) 2019-09-15 21:43:22 +02:00
Andrei Arlou
f3b0badcef
Add Andrei Arlou in copyright list (#1906) 2019-09-15 13:37:42 +03:00
Andrei Arlou
c044a87969
#1889 Remove unused parameters from classes TargetTypeSelector, ValueMapping, MethodRetrievalProcessor (#1890) 2019-09-14 04:12:38 +03:00
Andrei Arlou
2043506179
#1895 Refactor class org.mapstruct.ap.internal.util.Filters (#1896) 2019-09-14 03:57:42 +03:00
Andrei Arlou
3868735da7
#1897 Remove unused methods from class SourceMethod (#1898) 2019-09-14 03:43:27 +03:00
Andrei Arlou
7af107c9f2
#1883 Remove not used method "asCollectionOrMap" from TypeFactory (#1884) 2019-09-14 03:24:43 +03:00
Andrei Arlou
f95648cef8
#1088 Refactor constructor ForgedMethod (#1888) 2019-09-14 03:03:13 +03:00
Andrei Arlou
e068564017
#724 Remove JaxbMapper from integration test (#1892) 2019-09-14 02:48:22 +03:00
Sjaak Derksen
e12f9ffd7b
Refactoring of BeanMapping and Source/TargetReferences (common base class) (#1903) 2019-09-13 19:41:06 +02:00
Sjaak Derksen
6d9a50601e
#1867 refactor make the source model only a reflection of the source (#1868) 2019-09-12 20:21:39 +02:00
Andrei Arlou
3fd29f3ff9
Merge pull request #1879 from Captain1653/asccii_doctor_split_reference
#991 Split reference guide source into an adoc file per chapter
2019-08-26 22:45:16 +03:00
Andrei Arlou
ba90c95f23 #991 Split reference guide source into an adoc file per chapter 2019-08-24 20:51:16 +03:00
Andrei Arlou
8e37159a00 Fix minor warnings:
remove unnecessary generic type for collections,
remove unnecessary exceptions from signature,
fix typos
2019-08-24 09:23:58 +02:00
Andrei Arlou
55048ab045 Simplify consistent checks in class Mapping 2019-08-19 20:43:14 +02:00
Andrei Arlou
ee8f9283f2 Simplify conditions in package org.mapstruct.ap.internal.model
and classes: Conversions.java, MappingResolverImpl.java,
EclipseAsMemberOfWorkaround.java
2019-08-18 21:01:05 +02:00
Andrei Arlou
59a5182dab Fix minor warnings:
remove unnecessary generic type for collections,
replace Charset.forName on StandartCharset
2019-08-18 16:24:14 +02:00
Andrei Arlou
dbe761e738 Fix minor warnings in packages test and testutil:
remove unnecessary generic types for collection,
replace numbers months on Calendar constants,
remove unnecessary exceptions from signature test methods
2019-08-18 15:53:50 +02:00
Andrei Arlou
1ee59fd123 Fix minor warnings in tests, packages internal, spi and some others packages:
remove unnecessary generic-type in collections, simplify conditions,
remove unnecessary exception from signature,
replace months numbers on Calendar constants
2019-08-18 12:20:07 +02:00
Andrei Arlou
148466ae3e Fix minor warnings in package test.collection:
remove unnecessary generic-type in collections,
remove unnecessary exception from signature,
replace months numbers on Calendar constants
2019-08-18 12:13:40 +02:00
Andrei Arlou
dc86d5df45 Fix minor warnings in test packages java8stream and nestedbeans:
remove unnecessary generic types from collection,
remove unnecessary throws from test methods,
simplify equals in test dto
2019-08-18 12:11:01 +02:00
Andrei Arlou
281b792cf6 Fix minor warnings in test package bugs:
remove unnecessary generic type for collections,
remove unnecessary exceptions from signature test methods
2019-08-18 10:11:57 +02:00
Sjaak Derksen
66e57b0dfe
#1862 Update @MappingTarget documentation to take builders (#1864) 2019-08-13 18:44:49 +02:00
Andrei Arlou
716b85aa2c Simplify conditions in org.mapstruct.ap.internal.model.source 2019-08-11 22:18:15 +02:00
Andrei Arlou
f02b3d1a42 Remove unnecessary generic type in Collections.empty*,
replace "for" on Stream API,
replace anonymous classes on lambda
2019-08-11 14:48:08 +02:00
Andrei Arlou
e5c5550182 Fix warning addAll in org.mapstruct.ap.internal.model.assignment
Fix typo in org.mapstruct.ap.internal.model.common.Type
2019-08-11 14:45:45 +02:00
Filip Hrisafov
5f2a53afe1 Use trusty dist for JDK 8 build, add OpenJDK13 build and remove OpenJDK12 build 2019-08-11 09:04:54 +02:00
Sjaak Derksen
7bee12138d
#1307 & #1845 remove deprecated enummapping & create ST - refs under bean mapping
#1307 remove deprecated enum mapping 
#1845 create source / target references under bean mapping
2019-07-18 07:20:22 +02:00
Jonathan Kraska
119826982a #1826: fixed null pointer in nested property mapping when using presence checking (#1827) 2019-05-26 17:41:44 +02:00
Sjaak Derksen
d50e41cdbb
#1776 adding a message when no qualifiers are found (#1786) 2019-05-25 18:14:00 +02:00
Matt Drees
9c33199a66 Improve terms in qualifier docs (#1814)
This sentence is talking about `@Target`, not `@Retention`.
Also, let's use 'type' instead of 'class' to line up with `ElementType.TYPE`.
2019-05-25 11:34:30 +02:00
Sjaak Derksen
33710584d3
#1742 & #1661 refactoring and making builder optional (#1811) 2019-05-24 23:30:16 +02:00
Filip Hrisafov
60c159a0a1
#1751 Fix handling of possible builder creation methods with generic signature
When a method has a generic signature and the builder type is generic then the method return type does not match the builder type.
Therefore check only for raw types.
Add extra check for void method since a void method can't be a builder creation method
2019-05-24 23:26:25 +02:00
Sjaak Derksen
648ebceb30
#1819 documentation clarification on obtaining Mapper (#1820) 2019-05-16 22:23:37 +02:00
Filip Hrisafov
1415e32761
#1797 Use EnumSet.noneOf when creating a new instance of EnumSet 2019-05-05 12:42:25 +02:00
Sjaak Derksen
871353fccb
#1784 NullValueMappingStrategy.RETURN_DEFAULT refers wrongly to primitive types (#1785) 2019-04-07 21:38:22 +02:00
Sjaak Derksen
da8c1d0e4b
#1772 unmapped source prop remaining when target and source entry diff (#1778) 2019-04-07 21:37:36 +02:00
Christian Bandowski
f82522fa77
[#1457] Stricter matching for lifecycle methods / non-unique parameters (#1782)
In case a lifecycle method has multiple matching parameters (e. g. same type)
all parameter names must match exactly with the ones from the mapping method,
otherwise the lifecycle method will not be used and a warning will be shown.
2019-04-07 18:56:05 +02:00
Christian Bandowski
7a19b2ba75
Merge pull request #1783 from chris922/update-readme
Update Readme / Java 1.8 required
2019-04-03 22:02:06 +02:00
Christian Bandowski
3ca4c3fcef Update Readme 2019-04-03 20:29:10 +02:00
power721
7e112ccc2f Fix typo and code error in documentation (#1779)
* fix typo in documentation "Using builders"

* fix generated code example in stream mapping
2019-04-03 20:21:08 +02:00
Filip Hrisafov
3790f1919a
Make hickory an optional dependency as well (#1765)
Using optional because IntelliJ is picking up hickory as a transitive
dependency and runs the hickory processor in projects using mapstruct-processor.
This happens only when the processor is defined in the maven-compiler annotationProcessorPaths.
This is related to https://youtrack.jetbrains.com/issue/IDEA-200481.
2019-03-30 09:47:35 +01:00
Sjaak Derksen
6c838e6e0c
#1714 Qualifiers should not qualfiy when no qualfier is found (#1739) 2019-03-23 22:08:18 +01:00
Filip Hrisafov
f5ee2c6729
Remove use of prerequisites from parent pom.xml (#1766) 2019-03-23 21:27:15 +01:00
Filip Hrisafov
39481f98c5
Update checkstyle to latest version and replace deprecated methods (#1764) 2019-03-23 21:25:08 +01:00
juliojgd
63c5fc8eff Fix typo in documentation (#1760)
It is "then" instead "than
2019-03-20 21:37:47 +01:00
Sjaak Derksen
fcf96c36eb
#1756 better forged method error based on empty target bean properties (#1757) 2019-03-19 09:44:27 +01:00
Sjaak Derksen
b53741d960
#37 Rudimentary logging in mapstruct (#1741)
* #37 Rudimentary logging in mapstruct

* #37 Rudimentary logging in mapstruct changed order

* #37 rework

* #37 documentation

* #37 comments

* #37 docmentation revisited

* #37 review comments

* #37 unit test

* #37 unit test fixing empty mapper

* #37 rework comments christian

* #37 adding deferred mapper logging

* #37 adding unit test for deferred mapper logging

* #37 processing comments Filip
2019-03-17 16:45:22 +01:00
Filip Hrisafov
bc010a52dc #1738: Use typeBound for the return type of the nested property mapping method and for the definition of the properties within the method 2019-03-15 20:36:03 +01:00
Filip Hrisafov
4f2f546ffc Update plugins to latest versions 2019-03-15 20:35:13 +01:00
Filip Hrisafov
07590cc0d1 Add Open JDK 12 to the Travis CI matrix 2019-03-09 21:50:57 +01:00
Filip Hrisafov
b9b9b60a38 Travis CI deploy snapshots only from the mapstruct/mapstruct repo + skip build of distribution when deploying 2019-03-09 21:39:41 +01:00
Filip Hrisafov
5e96dc8085 Deploy coverage reports only on JDK 8 + deploy snapshots only from JDK 8 build 2019-03-09 21:17:16 +01:00
Filip Hrisafov
3e6ea0ef8f Update Javadoc and set source to 8 for proper compilation on Java 11
See https://bugs.openjdk.java.net/browse/JDK-8212233 for more information
2019-03-09 20:19:28 +01:00
Filip Hrisafov
92bed79144 Fix .travis.yml 2019-03-09 20:05:41 +01:00
Filip Hrisafov
643cc85e50 #1675 Tests should run properly in Java 11
* Add Travis CI build matrix to run build on OpenJDK 11 and EA
* Add regex for the Java 11 Generated annotation in order for the JavaFileAssert to work properly
* Do not use eclipse compiler if running on Java 9+
* Add JDK11 util compiler that reports all errors (also when multiple on same line)
* Whitelist jaxb-api to the test compilation classpath
* Add specific ignores for running some tests with Java 11 (See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+)
2019-03-09 19:54:40 +01:00
Gunnar Morling
ae3758674a #1675 Making MapStruct compileable with OpenJDK 11 2019-03-09 19:54:40 +01:00
Sjaak Derksen
98d86cee84
#1745 refactoring source reference (#1746) 2019-03-09 18:36:33 +01:00
Sjaak Derksen
6c1108d5bb
#1698 Skip "java.lang.Object" as intermediate result additional unit test (#1737) 2019-02-25 20:56:28 +01:00
Sjaak Derksen
51bd43fc1b
#1719 strange error message for selecting collection update methods (#1724) 2019-02-25 19:47:53 +01:00
Xavier RENE-CORAIL
002a8b0562 Add LGTM.com code quality badges 2019-02-19 21:49:25 +01:00
Filip Hrisafov
635cdbf4ea
Add Thibault to copyright.txt 2019-02-14 22:27:43 +01:00
Thibault Duperron
60208b67af #1435 add import to MapperConfig 2019-02-14 22:24:42 +01:00
Sjaak Derksen
23608477b7
#1698 Skip "java.lang.Object" as intermediate result in 2 step mappings (#1712) 2019-02-12 10:17:50 +01:00
Sjaak Derksen
160549a788
#1142 update documentation (#1710)
* #1142 update documentation

* #1142 comment
2019-02-10 22:08:38 +01:00
Filip Hrisafov
d282261ddf Update latest release badge and update readme with 1.3.0.Final 2019-02-10 12:28:04 +01:00
Filip Hrisafov
a28f2cb9cf [maven-release-plugin] prepare for next development iteration 2019-02-10 11:48:20 +01:00
Filip Hrisafov
984423dfee [maven-release-plugin] prepare release 1.3.0.Final 2019-02-10 11:48:19 +01:00
Filip Hrisafov
9762082703 Use Java 8 Javadoc links 2019-02-10 11:43:19 +01:00
Sjaak Derksen
3c079e412a
#1707 fix for not defining local variable in stream-iterable mapping (#1708) 2019-02-10 10:31:51 +01:00
Filip Hrisafov
eca7433103 #1694 Avoid circular dependency between model and conversion packages
Remove import of SimpleConversion used in the javadoc of the BuiltIntMethod

Fixes #1694
2019-02-10 09:09:17 +01:00
Filip Hrisafov
2ea5dcf400
Add Andres and Taras to copyright.txt 2019-02-09 21:38:24 +01:00
Sjaak Derksen
07c7a29adc
#1700 Optimizing code for adders and stream adders (#1701) 2019-01-29 20:02:23 +01:00
Sjaak Derksen
0981959ff0
#1699 add sensible defaults to NullValuePropertyMapping.SET_TO_DEFAULT (#1702) 2019-01-28 22:47:37 +01:00
Filip Hrisafov
884ca2507a
Mark the Immutables BuilderProvider and AccessorNamingStrategy and the FreeBuilderAccessorNamingStrategy as Experimental (#1692) 2019-01-27 21:21:25 +01:00
Sjaak Derksen
57caee250f
#1685 completing nullvaluepropertymappingstrategy (#1697) 2019-01-27 21:09:44 +01:00
Andres Jose Sebastian Rincon Gonzalez
abd1cfb6a1 #1695 update gradle installation 2019-01-22 22:49:30 +01:00
Filip Hrisafov
73a1ab1e8a
#1681 Do not call finaliser method on return when @MappingTarget is not a builder 2019-01-20 17:05:52 +01:00
Filip Hrisafov
b46682f95b Go back to using 3.0.0-M1 of the maven-enforcer-plugin
Once https://issues.apache.org/jira/browse/MENFORCER-306 is fixed we can upgrade the plugin again
2019-01-20 15:28:55 +01:00
Christian Bandowski
0e33ad4bbc #1657 Add Mappers.getMapperClass for getting the class of a Mapper 2018-12-22 15:19:39 +01:00
Sjaak Derksen
743361ca45
#1650 cannot find symbol nested mapping mappingtarget (#1671)
* #1650 reproducer

* #1650 fix cannot-find-symbol

* #1650 reproducer, extended
2018-12-20 21:12:37 +01:00
Filip Hrisafov
8edc6f82aa
Add Arne to copyright.txt 2018-12-11 18:36:09 +01:00
Arne Seime
e2915c864e #1665 Box any primitives before attempting type comparison for adder accessors 2018-12-11 18:33:50 +01:00
Taras Mychaskiw
780fd73928 #1656 Support for mapping between String and java.time Duration, Period, Instant 2018-12-08 20:25:42 +01:00
Filip Hrisafov
d1fe65dbad #1660 Consider only public not static accessor methods as possible getter, setter, presence check and / or adder methods 2018-12-01 21:26:55 +01:00
Filip Hrisafov
9a43b210d3 Add since tag to new API elements 2018-11-24 02:07:31 +01:00
Filip Hrisafov
a3ba57c372
#1648 Source properties defined in Mapping should not be reported as unmapped 2018-11-18 10:11:11 +01:00
Sjaak Derksen
b651ad34b5
#1649 Improvement: builder for Mapper/Decorator/GeneratedType 2018-11-18 08:44:57 +01:00
Filip Hrisafov
2977c2e614
#1645 Use Repeatable Mapping annotation in the reference documentation 2018-11-11 13:57:42 +01:00
Filip Hrisafov
ced7f3b024 [maven-release-plugin] prepare for next development iteration 2018-11-11 09:19:06 +01:00
Filip Hrisafov
3f2c1cee55 [maven-release-plugin] prepare release 1.3.0.Beta2 2018-11-11 09:19:05 +01:00
Sjaak Derksen
cf668bea77
#1576 Delay determining whether a Type needs to be imported & java.time cleanup (#1642) 2018-11-06 07:36:09 +00:00
Filip Hrisafov
3ff4ebd60a #1640 Add init method with MapStructProcessingEnvironment to the BuilderProvider for initializing the Elements and Types 2018-11-03 15:48:16 +01:00
Sjaak Derksen
1266796921
#1504 adding position hints for ambiguous mapping methods (#1639) 2018-11-03 08:57:42 +00:00
Filip Hrisafov
60611d94cf Add more info for the FreeBuilder support in the documentation
* Add the usage of the FreeBuilderAccessorNamingStrategy when FreeBuilder is present
* And the fact that the JavaBean convention should be followed when using FreeBuilder
2018-11-03 09:03:22 +01:00
Filip Hrisafov
a0ae8750a1 Adapt japicmp-maven-plugin to not consider adding a new default method to an interface as incompatible
According to https://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.5.3
Adding an abstract (default) method to an interface does not break compatibility with pre-existing binaries.
2018-11-03 08:55:10 +01:00
Filip Hrisafov
104ebf88da Add a FreeBuilder specific AccessNamingStrategy
The builder created by FreeBuilder have different fluent methods created.
When using FreeBuilder one needs to use the JavaBean convention for the getters (as otherwise MapStruct won't recognize them),
this leads to FreeBuilder creating fluent setters that start with set (so we can safely ignore all other fluent setters)
2018-11-03 08:55:10 +01:00
Filip Hrisafov
6f19d56155 #1566, #1253 Add support for initializing the AccessorNamingStrategy with Elements and Types and use Types for determining fluent setters
* This allows using generic builders
2018-11-03 08:55:10 +01:00
Sjaak Derksen
e69647f756
#5 controlling lossy conversions (also solving #1504 partially and #1458) 2018-11-02 07:56:51 +00:00
Filip Hrisafov
ec413118d6
Update build with latest dependencies and Java 8 baseline: (#1636)
* Do not use maven-processor-plugin and use the maven-compiler-plugin annotationProcessors instead
* Update NoPackageCyclesRule and exclude tests
* Update checkstyle to 8.14 and remove FIleContentsHolder module and move SuppressionCommentFilter to the TreeWalker
* Update assertj to 3.11.1 and replace usage of RuntimeIOException (from AssertJ) with UncheckedIOException (from java 8)
* Add how to import MapStruct into IntelliJ and Eclipse into the readme
2018-10-28 21:39:35 +01:00
Filip Hrisafov
de13634cce
#1478 Use source property name for the adder iterator 2018-10-28 14:55:41 +01:00
Filip Hrisafov
2acbe0f5e8
#1633 Add support for an alternative line in the diagnostics report
* This should be used as a last resort when the compilers report the diagnostic on a wrong line
* The NullValuePropertyMappingTest uses repeatable annotations that reports errors on wrong lines in javac JDK-8042710
2018-10-28 08:01:44 +01:00
Sjaak Derksen
288813fc3c
#1306 Add new NullValuePropertyMappingStrategy which leaves @MappingTarget untouched (#1618) 2018-10-25 22:14:26 +01:00
dgruntz
cfe0f6250c Renames MAPPER field to INSTANCE (#1632) 2018-10-25 18:26:39 +01:00
Sjaak Derksen
a09d980773
#1593 additional testcase to test multiple source arguments icw @MappingConfig (#1630) 2018-10-20 11:21:13 +01:00
Florian Tavares
71e9bd3699 #1301 code improvements / adaptations after language-level upgrade 2018-10-19 20:36:07 +01:00
Florian Tavares
d81d3e46a4 #1301 Use Java 8 as baseline for MapStruct
* Move classes from mapstruct-common into mapstruct
* Use Java 8 @Repeatable for @Mappings and @ValueMappings in the mapstruct module
* Add relocation for mapstruct-jdk8 to mapstruct
* Use of 1.8 source and target versions from parent POM
* Update documentation to match
* Update versions of some maven plugin crashing build on Java 8
* Drop JDK 6 & 7 support in integration tests
* Remove mapstruct-common module (it was never deployed to Central)
2018-10-15 22:16:33 +02:00
Filip Hrisafov
20bff96e99
#1591 Update reference guide with implicit conversion between java.time.LocaDate and java.sql.Date 2018-10-15 21:46:23 +02:00
Sivaraman Viswanathan
9f8c0749d1 #1591 Add support for mapping java.time.LocalDate to java.sql.Date 2018-10-15 21:41:53 +02:00
Filip Hrisafov
6d5243dc2f #1551 Use javax.annotation.processing.Generated if it is available and source version is at least RELEASE_9 2018-10-13 19:07:24 +02:00
Filip Hrisafov
0e0fd313e5 #1594 Add test case to show that it has been fixed 2018-10-13 10:27:49 +02:00
Filip Hrisafov
f17ddcfb18 #1608 Make sure that property names for fluent setters starting with is are handled properly (#1620) 2018-10-13 07:54:09 +01:00
Sjaak Derksen
fa1ab4b781
Update copyright.txt 2018-10-13 08:46:16 +02:00
Filip Hrisafov
ef82ebfbca #1595 Update reference guide with implicit conversion between java.time.Instant and java.util.Date 2018-10-13 08:17:20 +02:00
neoXfire
6b3cbaae9e #1595 Support for conversion between java.time.Instant and java.util.Date (#1622) 2018-10-12 20:10:25 +01:00
Sjaak Derksen
4f539d2a08
#1616 Adding an issue template to streamline answers 2018-09-26 20:48:54 +02:00
Sjaak Derksen
459f57e805
#1571 apply nullvaluecheck strategy on all relevant levels 2018-09-24 23:35:35 +02:00
Filip Hrisafov
dcddba6853
Add Sebastian to copyright.txt 2018-09-24 22:26:43 +02:00
Sebastian
30c2dadec7 #1561 add support for adders in combination with streams
- 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
2018-09-24 22:23:34 +02:00
Sjaak Derksen
5a4990c474
#1456 apply source presence tracking recursively (in nested source) 2018-09-22 14:06:53 +02:00
Sjaak Derksen
13aa947421
#1569 Reproducer missing Immubable buildertype import (#1605) 2018-09-12 16:26:09 +02:00
Sjaak Derksen
3da85bc178
#1596 Missing builder type import (#1602) 2018-09-02 22:19:21 +02:00
Sjaak Derksen
bd2c206f7f
#1590 ArrayList missing as import for NVMS.RETURN_DEFAULT (#1598) 2018-08-29 21:11:22 +02:00
Filip Hrisafov
ded8d88c73
#1578 Rename isBuilderSetter to isFluentSetter in the DefaultAccessorNamingStrategy 2018-08-18 21:58:22 +02:00
Filip Hrisafov
04576de1d1
#1552 Stop processing source parameters for unprocessed defined properties when a mapping is found 2018-08-18 19:58:02 +02:00
Sjaak Derksen
10f855fa9e
#1532 using fields and constructor fragments optimizing DataTypeFactory usage 2018-08-14 23:53:41 +02:00
Sjaak Derksen
5c2e049478
#1558 Annotations ElementType.TYPE_USE not handled correctly 2018-08-14 06:56:59 +02:00
Filip Hrisafov
e056311c1a
#1569 Make sure that converting Java 8 LocalDate to Date generates correct code
* ZoneOffset instead of ZoneId needs to be imported when performing a conversion from LocalDate to Date
2018-08-13 21:21:04 +02:00
Filip Hrisafov
0d3ec9042d
Add Saheb to copyright.txt 2018-08-11 22:21:56 +02:00
Saheb Preet Singh
08067b7f17 #1524 replaced java.beans.Introspector with a custom IntrospectorUtils class to avoid java.desktop module 2018-08-11 22:19:21 +02:00
Christian Bandowski
6b89539ff6 #1541 Fix NPE when using varargs in mapping methods 2018-07-24 18:19:42 +02:00
Christian Bandowski
0fa964038c #1499 Add Protobuf builder integration test
* Don't run the ProtobufBuilderTest with the processor_plugin_java8 and eclipse_jdt_java_8 (processor plugin runs before the proto java classes are created and the eclipse plugin has some bug)
* Include *.proto for license checks
2018-07-15 20:53:13 +02:00
Filip Hrisafov
e29c25e5cb [maven-release-plugin] prepare for next development iteration 2018-07-15 19:51:45 +02:00
Filip Hrisafov
c189aa7bb5 [maven-release-plugin] prepare release 1.3.0.Beta1 2018-07-15 19:51:44 +02:00
Filip Hrisafov
12bfff8f46 #1411 Fix expected line in Diagnostic after reducing the test files copyright headers 2018-07-15 19:29:28 +02:00
MapStruct Team
b35126e609 #1411 Update copyright header on all files
* Use new shorter copyright header without a year
* Use SLASHSTAR_STYLE for Java files
2018-07-15 19:29:28 +02:00
Filip Hrisafov
347a436cda #1382 Change module for java.annotation.Generated in the documentation
closes #1382
2018-07-15 10:56:06 +02:00
Sjaak Derksen
58a2aa94bb
#1482 allowing generic self references in types when matching 2018-07-14 16:27:10 +02:00
Filip Hrisafov
616aaa986d #1479 Fix typos in the Javadoc 2018-07-12 23:30:37 +02:00
Filip Hrisafov
ef270caecb
#1479 Add support for Builders with multiple build methods (#1498)
* Add new @Builder annotation for defining a build method
* When there are multiple build methods look for a method named `build` and if found use it
* If @Builder is defined than look for a build method with the defined method
* When a type has multiple builder creation methods throw an exception and don't use the builder

Defaulting to a method named `build` will make sure that a correct method is selected for:
* FreeBuilder - it has two methods: `build` and `buildPartial`
* Protobuf - it has three methods: `getDefaultInstanceForType`, `build` and `buildPartial`
2018-07-12 23:16:53 +02:00
Filip Hrisafov
62ffa3fa43
Add Gervais to the copyright.txt 2018-07-12 22:14:56 +02:00
Gervais Blaise
c9bc1df132 Allow package-private mapper
Use and make the default constructor accessible to create the mapper
instance. 

fixes #1365
2018-07-12 22:12:09 +02:00
tomoya-yokota
81f82a54a5 Document of sample code is broken. 2018-07-11 20:29:08 +02:00
tomoya-yokota
e2c8559a62 Update document on gradle-apt-plugin 2018-07-11 20:21:53 +02:00
sngrekov
b03ca8b7a9 Add sample of @Mapping annotation to @InheritInverseConfiguration 2018-07-02 10:54:57 +02:00
tomoya-yokota
fc5f937a71 Fix Method name typo 2018-07-01 23:24:01 +02:00
Christian Bandowski
508de6733e #1523 dont lose timezone mapping Calendar to XMLGregorianCalendar 2018-06-21 22:32:36 +02:00
cvanburen
f4ed077aeb Documentation update, section 3, fixing typos 2018-06-05 23:05:21 +02:00
sjaakd
3a4fcb5bcb #1398 allowing @ObjectFactory methods on context, fixing javadoc 2018-05-24 22:51:51 +02:00
sjaakd
e67c849c17 #1398 allowing @ObjectFactory methods on context 2018-05-24 20:28:14 +02:00
Christian Bandowski
db851701ef #1454 add more tests for builder lifecycle methods 2018-05-17 21:39:38 +02:00
Christian Bandowski
eeddc17de4 #537 add unit test 2018-05-09 22:28:16 +02:00
sjaakd
6fbc4cf253 #1180 non existing (nested) property in shared config 2018-05-08 23:18:18 +02:00
Filip Hrisafov
771debee88
#1453 Make sure that we always forge iterable / map mapping methods without bounds
When generating collection / map mapping methods make sure that the method result type is without bounds
2018-05-06 22:03:16 +02:00
sjaakd
45cc87849b #1458 reporting error detail from literal assignment 2018-05-05 22:56:00 +02:00
Christian Bandowski
9e299a2ba1 Use constants instead of strings in ValueMapping javadoc 2018-05-05 22:19:27 +02:00
Christian Bandowski
b291907918 #1460 Ensures the FQN will be used for SimpleConversion if required
* 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
2018-05-05 20:42:37 +02:00
Filip Hrisafov
bf31ec72de
#1338 Using an adder with non generic source collection should work 2018-05-04 08:09:37 +02:00
Filip Hrisafov
7a3f6d973e
#1473 Make sure that the SPIs are lazy initialized in the AnnotationProcessorContext 2018-05-03 23:15:23 +02:00
Filip Hrisafov
b6905d5168 Make sure we have a conflicting test with adder 2018-05-03 21:51:37 +02:00
Filip Hrisafov
84bf019fdf More detailed check for adder in builde 2018-05-03 21:51:37 +02:00
Filip Hrisafov
adde6826a6 #1449 Adders should not be considered as builder setter methods 2018-05-03 21:51:37 +02:00
Filip Hrisafov
7306c52529 #1415 Use Immutables AccesorNamingStrategy and BuilderProvider when immutables are present
This allows out of the box support for Immutables by picking the right default strategy when immutables are present
2018-05-01 18:26:34 +02:00
Filip Hrisafov
8a24706026 Extract methods that use the AccessorNamingStrategy into class instance methods
This helps towards #1415, where we need to use strategy based on presence / absence of Immutables
2018-05-01 18:26:34 +02:00
Filip Hrisafov
720854913a Disable running the annotation processing in the module defining it 2018-05-01 18:26:34 +02:00
sjaakd
d92b439a60 #1462 define constants as JLS literal types, enforce long L suffix 2018-04-29 09:12:49 +02:00
sjaakd
ffb720dc29 #1459 javadoc on constant assigment 2018-04-29 09:12:49 +02:00
Filip Hrisafov
5c799b73ef
#1452 support BeanMapping#ignoreByDefault for builders 2018-04-28 10:17:52 +02:00
Filip Hrisafov
cf19a6b637
#1423 Updating types that have a builder should be allowed
It is possible that a type has both a builder and accessors.
In such case doing an update to this type should be allowed
2018-04-28 09:09:44 +02:00
Filip Hrisafov
7e7fcfbb94
#1317 Add support for ignoring unmapped source properties
This property has only effect on the unmapped source properties report
2018-04-25 20:45:02 +02:00
sjaakd
35f5400e00 #1401 improvements by direct assigning constants 2018-04-25 20:25:11 +02:00
Filip Hrisafov
2fe7f6be2b
#1387 Improve error message when unknown source parameter is used in Mapping 2018-04-24 21:39:28 +02:00
Filip Hrisafov
4a05c8d5f1
#1433 Support for lifecycle methods for builders
When doing mappings with builder the effective type should be considered for lifecycle callback methods
2018-04-24 21:36:48 +02:00
Filip Hrisafov
47ffb04106 #1436 Add since tag to new API elements 2018-04-22 16:33:14 +02:00
Filip Hrisafov
2f44bab9c9
Add Christian to copyright.txt 2018-04-21 19:07:59 +02:00
Christian Bandowski
5540efc482 #1425 Added findType to VirtualMappingMethod and use it in all builtin templates
Together with the includeModel directive this will ensure that the type will be written to the file as a FQN if required, otherwise as a simple name.
2018-04-21 18:59:29 +02:00
sjaakd
4f5db83de7 #1392 add option to default ignoreAll mappings in a bean mapping method 2018-04-21 09:07:13 +02:00
Christian Bandowski
72bf87f409 Remove cloudbees CI links and add travis-ci to readme 2018-04-19 19:39:43 +02:00
Lauri Apple
f63903a822 Update readme.md 2018-04-17 20:29:40 +02:00
Lauri Apple
721e3efec2 Update readme.md 2018-04-17 20:29:40 +02:00
Lauri Apple
60f27dbafc Update readme.md 2018-04-17 20:29:40 +02:00
Filip Hrisafov
43a9419c33
#1417 Add documentation about the builder support 2018-04-15 10:31:45 +02:00
Filip Hrisafov
5834368b15
#1431 Factory method resolution should be done on the effective type
This allows using factories for builder types as well
2018-04-15 10:19:58 +02:00
Filip Hrisafov
050e893c51
Add David to copyright.txt 2018-04-15 09:35:33 +02:00
dvfeinblum
075d2c4113 #1383 Invalid @Mapping values should be reported on the @Mapping annotation 2018-04-15 08:33:00 +02:00
Filip Hrisafov
18fa0a5b1a #1414 Pass originating mapper element to the Filer API 2018-04-11 20:11:12 +02:00
Filip Hrisafov
beea141255 #1338 Always determine collection argument type when searching for adder
If the Collection type is not actually generic it has no type parameters.
However, it's type argument can be determined.
One such list exists in protobuf (ProtocolStringList)
2018-04-08 15:28:41 +02:00
Filip Hrisafov
42d7bfe54d #1359 Collection target should be considered as immutable if there is no read accessor 2018-04-08 15:27:08 +02:00
Filip Hrisafov
db6805f100 #1418 Add support for NoOp BuilderProvider for turning off using of builders 2018-04-08 11:30:38 +02:00
sjaakd
e368b34ea4 #1370 avoid errors when Joda is not on classpath 2018-04-07 12:24:43 +02:00
Filip Hrisafov
2d8af2960b
Add Eric to copyright.txt 2018-04-04 19:48:46 +02:00
sjaakd
3b9d5413f4 #782 Use more desriptive names in tests 2018-04-04 19:26:22 +02:00
sjaakd
768a739a09 #782 Add tests with nested flattening target 2018-04-04 19:26:22 +02:00
sjaakd
045532fa68 #782 Add tests with nested expanding target 2018-04-04 19:26:22 +02:00
sjaakd
998d6fc35f #782 Add tests with expressions and constants 2018-04-04 19:26:22 +02:00
sjaakd
6291631af7 #782 Adding negative test for @MappingTarget with immutable classes 2018-04-04 19:26:22 +02:00
Filip Hrisafov
73711cc683 #782 Rename Lombok Integration test classes 2018-04-04 19:26:22 +02:00
Filip Hrisafov
2b9fdac7f7 #782 Wording cleanup after PR review 2018-04-04 19:26:22 +02:00
Filip Hrisafov
ee439d84c5 #782 Add javadoc to the new spi elements 2018-04-04 19:26:22 +02:00
Filip Hrisafov
06a49090cc #782 Nested target properties should work for builders as well 2018-04-04 19:26:22 +02:00
Filip Hrisafov
c3f0099698 #782 Do not use JDT for the Lombok integration tests
Lombok uses internals of the Java and Eclipse compilers.
In order for it to work with the Eclipse compiler, we need to add some extra jar.
Therefore, we are only testing Lombok with the Java compiler
2018-04-04 19:26:22 +02:00
Filip Hrisafov
22c337a947 #782 Add custom SPI implementations for Immutables in the integration tests 2018-04-04 19:26:22 +02:00
Filip Hrisafov
252af70bae Add new processor suite that ignores the maven procesor plugin
The maven-processor-plugin does not take classpath dependencies during the processing
2018-04-04 19:26:22 +02:00
Filip Hrisafov
45abe9e35b #782 Add BuilderInfo to SPI
The implementors of the SPI should return all the required information
2018-04-04 19:26:22 +02:00
Filip Hrisafov
d99a4cc217 #782 Add support for mapping immutable classes with builders 2018-04-04 19:26:22 +02:00
Filip Hrisafov
70419f91b0 #782 The builder type from lombok is not present during the annotation processing phase 2018-04-04 19:26:22 +02:00
Filip Hrisafov
dbc7c8a84d #782 Add integration tests for builders with FreeBuilder 2018-04-04 19:26:22 +02:00
Filip Hrisafov
45ab6e1c52 #782 Add integration tests for builders with AutoValue 2018-04-04 19:26:22 +02:00
Filip Hrisafov
bf8f037a19 #782 Add integration tests for builders with immutables 2018-04-04 19:26:22 +02:00
Eric Martineau
3d45d072e7 #782 Add tests for builders 2018-04-04 19:26:22 +02:00
Filip Hrisafov
4693a2581c MethodReference should not extend MappingMethod 2018-04-04 19:26:22 +02:00
Filip Hrisafov
2ead42da25
#1378 Use Types instead of searching for type elements 2018-03-18 20:36:00 +01:00
Filip Hrisafov
f2ef330304
Use correct link for the JAXBBasedMapperTest 2018-03-18 11:18:55 +01:00
sjaakd
6b363f87c1 #1367 aligning @Inherit(Inverse)Conf. with strategy AUTO_INHERIT_* 2018-03-17 09:00:57 +01:00
Filip Hrisafov
49efb4fd6c
#1395 Unused mappers should not be used in constructor injection 2018-03-14 21:29:18 +01:00
Jeff Smyth
48b9bd72be #1363 Add support for using default expression 2018-02-19 23:01:51 +01:00
Darren Rambaud
8f88c6baa7 #1355: Adds Implicit Conversion Between java.util.Currency <~> String (#1381)
* #1355: Setting up the test(s) for new conversion between java.util.Currency and String

* #1355: Added SimpleConversion subclass to convert a Currency object to a String object and vice-versa, and registered the class to Conversions

* #1355: Initial tests written, may need to re-write some test files for readability and/or add more test case(s). Basic tests are passing at this time

* #1355: Added copyright statement, added documentation for new implicit conversion

* #1355: Added clarity to documentation

* #1355: Replaced use of one letter variables

* #1355: Resolved CheckStyle errors

* #1355: Fixes license header spacing so the license plugin no longer fails the build

* Small cleanups
2018-02-18 19:02:56 +01:00
Filip Hrisafov
d5bb33f51d
#1375 Allow using target references when there is no intermediary read accessor 2018-02-11 12:48:40 +01:00
sjaakd
24ca295448 #1345 adapting fault message empty constructor to parameterless 2018-01-30 23:16:29 +01:00
sjaakd
5707f35c85 #1345 cleanup non required isReverse in printing messages 2018-01-30 23:16:29 +01:00
sjaakd
4c1dcc5272 #1345 ignoring reversed mappings with no target accessor silently 2018-01-30 23:16:29 +01:00
Daniel Strobusch
3d26318301 Fixed caption of listing 2018-01-14 11:56:35 +01:00
Filip Hrisafov
6dee8fbe66
Add Jeff to copyright.txt 2017-12-29 22:33:29 +01:00
Jeff Smyth
f31d234ba0 #1353 Add a trim for source and target mappings, but log a warning message if trimmed. 2017-12-29 22:18:20 +01:00
Filip Hrisafov
3f8b1e46d4
#1320 Properly create additional options for unprocessed defined targets
Create mappings for each unprocessed defined target based on their name and the mapping
2017-11-26 22:23:02 +01:00
Filip Hrisafov
460e87eef6 #1340 Create correct overriden method for Value Mappings
* 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
2017-11-24 00:48:19 +01:00
Filip Hrisafov
2190ae324b #1339 Primitive Context parameters should be skipped when looking for lifecycle methods 2017-11-24 00:44:33 +01:00
Filip Hrisafov
1af702e44b Polish after PR merge
* Extract common TypeMirror extraction into a separate method
* Remove not needed code from tests
2017-11-23 23:51:18 +01:00
Filip Hrisafov
faabbf7ec0 Add Richard and Joshua to copyright.txt 2017-11-23 23:45:08 +01:00
Richard Lea
49e39e0ed5 #1332 Fix exceptions declaration missing in generated nested private methods 2017-11-23 23:41:42 +01:00
Filip Hrisafov
e4839fce5d #1333 Add since tags for unmappedSourcePolicy() 2017-11-18 09:34:25 +01:00
Filip Hrisafov
3df399f693 #1314 Fix some typos 2017-10-23 20:02:09 +02:00
Kevin Grüneberg
a0b60a6bf4 #1314 Injection Strategy docs 2017-10-23 19:59:03 +02:00
Filip Hrisafov
a3e7b0a20a #610 remove unmapped source policy processor option 2017-10-22 23:20:03 +02:00
spoerri
92fe1093e4 #610 Add support for unmappedSourcePolicy 2017-10-22 21:06:17 +02:00
Kevin Grüneberg
946b8c8631 #1312 Change MapStruct Version in README to latest 1.2.0.Final 2017-10-20 23:28:41 +02:00
Filip Hrisafov
8143aa81e2 #571 Add test for default injection strategy 2017-10-20 22:56:48 +02:00
Kevin
0192bdaf83 #571 Add Constructor Injection for Annotation Based Component Model
- Allow configuring of injection strategy (Constructor / Field)
- Default injection strategy is Field
2017-10-20 22:56:48 +02:00
Kevin Grüneberg
e2391df04f #1297 Add IntelliJ Formatter to CONTRIBUTING.md 2017-10-20 21:26:38 +02:00
Filip Hrisafov
bfa2509439 Update latest stable badge with 1.2.0.Final 2017-10-18 00:06:29 +02:00
Filip Hrisafov
de76a87019 [maven-release-plugin] prepare for next development iteration 2017-10-17 23:12:53 +02:00
Filip Hrisafov
a2176493e7 [maven-release-plugin] prepare release 1.2.0.Final 2017-10-17 23:12:52 +02:00
Filip Hrisafov
0e8c22c95f Add Darren to copyright.txt 2017-10-17 22:14:35 +02:00
Filip Hrisafov
aef1e3b14b #1304 Add thrown exceptions to the generated nested mapping methods 2017-10-17 21:10:59 +02:00
Filip Hrisafov
22e17f9c4b #744 Improve support for Java 9
When compilig with Java 9 and and source version 1.8 Elements#getTypeElement(CharSequence) returns the types from all modules (such as java.xml.bind or java.xml.datatype).
However if the required modules are not added the classes cannot be used. Therefore, apart from using the Elements we are also checking if the class is also there.

If source version 9 is used then Elements#getTypeElement(CharSequence) works correctly and does not return the types if the modules are not there
2017-10-17 20:57:05 +02:00
Filip Hrisafov
98bdc3612f Adding Kevin to copyright.txt 2017-09-17 23:22:59 +02:00
Kevin Grüneberg
499dbd4561 #1273 Fix for NullValueMappingStrategy#RETURN_DEFAULT when using collections
When mapping a collection using NullValueMappingStrategy#RETURN_DEFAULT and the source is null, the target will be an empty collection.
2017-09-17 23:03:24 +02:00
Filip Hrisafov
af8d48c797 #1281 Do not depend on deprecated sonatype parent 2017-09-07 17:47:18 +02:00
Filip Hrisafov
779c16cc2a #1283 Handle no suitable empty constructor during BeanMappingMethod creation 2017-09-07 17:44:53 +02:00
Thomas Eckl
47697a2391 Fix a few errors in reference guide and readme 2017-09-03 18:42:01 +02:00
Filip Hrisafov
079d14d12e Run build in VM (fixes issues when build is killed by Travis containers) 2017-09-03 16:30:19 +02:00
Filip Hrisafov
1be6d352bb Switch to OpenJDK 7 on Travis (Oracle Java 7 is no longer present) 2017-09-03 16:29:04 +02:00
Filip Hrisafov
e79949ed0f [maven-release-plugin] prepare for next development iteration 2017-08-28 20:22:54 +02:00
Filip Hrisafov
322e77e52b [maven-release-plugin] prepare release 1.2.0.CR2 2017-08-28 20:22:54 +02:00
Filip Hrisafov
5cead7ae5e #1269 use update methods for different sources for nested targets 2017-08-27 18:59:17 +02:00
sjaakd
4d8bc29347 #1255 Extension of autoInheritanceStrategy, removing of name based ignore reverse mapping 2017-08-23 22:54:10 +02:00
Filip Hrisafov
6377e51efa #1251 Deploy SNAPSHOTS from Travis CI 2017-08-18 19:41:24 +02:00
Filip Hrisafov
17da0cf912 #1231 Add japicmp for the MapStruct API 2017-08-17 00:10:04 +02:00
Filip Hrisafov
2f4cf7c905 #748 Add note that the passed parameter to MappingTarget must not be null 2017-08-16 22:19:49 +02:00
Darren Rambaud
d0bd0a2fdf Fixed a couple of typos (#1260)
* Fixed 2 typos in the documentation
2017-07-24 19:33:46 +02:00
Filip Hrisafov
0540a00263 [maven-release-plugin] prepare for next development iteration 2017-07-15 10:21:42 +02:00
Filip Hrisafov
03f6434aa7 [maven-release-plugin] prepare release 1.2.0.CR1 2017-07-15 10:21:41 +02:00
Darren Rambaud
b2e3ff0727 Fixed a minor typo
On line 14, changed "repostory" to "repository"
2017-07-14 23:07:59 +02:00
Filip Hrisafov
db3bb5eba0 #1247 Make sure that nested target mappings works correctly for multiple source parameters 2017-07-13 18:52:57 +02:00
Andreas Gudian
d9821a0cc8 #1242 Fix favoring of a single factory method with source params before others without source params.
From the Javadoc of @ObjectFactory: If there are two factory methods, both serving the same type, one with no parameters and one taking sources as input, then the one with the source parameters is favored. If there are multiple such factories, an ambiguity error is shown.
2017-07-11 23:03:44 +02:00
Filip Hrisafov
3004ea28c5 #1131 Use SourceRHS source type for update methods factories
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
2017-07-11 21:53:38 +02:00
Filip Hrisafov
3ebd09eec9 #1244 Fix problems with special word for FreeMarker in some cases 2017-07-10 20:37:09 +02:00
Filip Hrisafov
acdab55604 #1196 Use dedicated property name for the jacoco argument line and have an empty property in order to work with Netbeans 2017-07-09 11:12:15 +02:00
Gunnar Morling
ca0721d931 #1224 Adding Automatic-Module-Name headers to mapstruct, mapstruct-jdk8 and mapstruct-processor JARs 2017-07-08 15:24:39 +02:00
Filip Hrisafov
c983b6d1e4 Adding Tillerino to copyright.txt 2017-07-07 19:06:28 +02:00
Tillerino
00385a1cdb #611 Allow nested declaration of Mappers
* #611 Allow nested declaration of Mappers

Up until now, if a Mapper was declared as a nested interface, say
EnclosingClass.NestedMapper, the implementation of the mapper was
generated as NestedMapperImpl in the same package. The Mappers factory
class then tried to load EnclosingClass$NestedMapperImpl, which would
fail.
2017-07-07 19:03:56 +02:00
Gunnar Morling
3b9584ff13 #883 Adding Alexander to copyright.txt 2017-07-07 18:03:35 +02:00
Gunnar Morling
aae1527352 #883 Simplifying look-up of test locale 2017-07-07 17:52:20 +02:00
Alexandr Shalugin
614f0ea4ee #883 generated variable names with ı instead i 2017-07-07 17:52:20 +02:00
Gunnar Morling
dfbe8767a5 #543 Adding assertion to test that the bound type is added to the import statements 2017-07-06 17:08:58 +02:00
Filip Hrisafov
82da71199d #543 Make sure that the bound type is imported if the type is wildcard 2017-07-02 20:25:35 +02:00
Filip Hrisafov
dc031bf916 #1185 display the specific type for a property for which no write accessor exists or it is unknown 2017-06-29 23:15:48 +02:00
Filip Hrisafov
324e1fadbe #1086 Mention the fact that prototype methods are not considered for automatic sub mapping methods 2017-06-29 23:04:05 +02:00
Filip Hrisafov
7a9464c525 #1150 Improve error reporting for nested properties 2017-06-29 20:25:42 +02:00
Filip Hrisafov
a3eca8c8ca #1170 Adding Cornelius Dirmeier to copyright.txt 2017-06-29 00:05:05 +02:00
Cornelius
b5b0c04313 #1170 Fix wildcards in collection adder mappings 2017-06-29 00:01:49 +02:00
Filip Hrisafov
89d7463c93 #1219 Mention ability to turn of automatic sub-mapping generation in documentation 2017-06-27 20:33:45 +02:00
Filip Hrisafov
e6d5831aa7 #1227 Make sure that only types belonging to java.lang are not imported 2017-06-27 20:30:50 +02:00
Filip Hrisafov
0d66618d45 [maven-release-plugin] prepare for next development iteration 2017-05-30 23:27:41 +02:00
Filip Hrisafov
b3e7c52076 [maven-release-plugin] prepare release 1.2.0.Beta3 2017-05-30 23:27:40 +02:00
Filip Hrisafov
2acaffa3ec #1129 Add forbidden apis plugin to fail on illegal TypeMirror usages 2017-05-30 22:56:31 +02:00
Filip Hrisafov
9fc111f7df #1129 Do not use equals and hashCode from TypeMirror 2017-05-30 22:33:18 +02:00
Filip Hrisafov
ceaa869c65 #1215 Add import correctly for array types 2017-05-30 21:35:39 +02:00
Filip Hrisafov
6187a72a2b #1148 Always add the generated MappingMethod if the MappingOptions are restricted to the defined mappings 2017-05-24 22:32:05 +02:00
Filip Hrisafov
2e09944b19 #1213 General code cleanups:
* #122 Use util methods when possible
* Fix some warnings in Javadoc generation
* Don't use raw classes when not needed
* Add .yml, binding.xjb and .asciidoc files to license check exclusion
2017-05-24 14:15:46 +02:00
Filip Hrisafov
f2ad90042c Update assertj and used dedicated method in tests (#1204) 2017-05-24 08:07:59 +02:00
Filip Hrisafov
70dbdcde0d Disable codecov/patch statuses 2017-05-23 22:13:52 +02:00
navpil
75fa2fb0f7 #122 Minor formatting changes 2017-05-20 08:38:00 +02:00
navpil
5dd0097cc9 #122 Suggest property name in error message when referring to a non-existent property 2017-05-20 08:38:00 +02:00
Filip Hrisafov
9415bb0999 Add travis, codecov, license and gitter badges 2017-05-17 22:44:09 +02:00
Filip Hrisafov
65b0e4d3c5 #1194 Setup code coverage analysis with codecov 2017-05-17 22:44:09 +02:00
Filip Hrisafov
7cf77f4c26 #1154 Add SPI for excluding types/elements from automatic sub-mapping generation
Default implementation of SPI ignores types in the java/javax packages
2017-05-17 22:34:23 +02:00
Filip Hrisafov
459354b6b8 #1153 Do not use invalid TargetReferences when creating nested target mappings
* Move the error generation for the invalid TargetReference into the BuilderFromTargetMapping
* TargetReference will strip the first entry name in the following cases only if the first entry name matches the MappingTarget parameter, or for reverse mappings it matches the source parameter name
* Pass the reverse source parameter when initializing a reverse mapping
2017-05-06 23:26:51 +02:00
Filip Hrisafov
aa6cda1177 Use anchors for the sections and add Filip to the authors 2017-05-06 15:15:16 +02:00
Filip Hrisafov
15133d5a0f #777 Set initial capacity for new collection / map element in collection / map mappings 2017-05-06 15:04:42 +02:00
Filip Hrisafov
763deaa917 #1164 Split the SetterWrapperForCollections into multiple models:
* 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
2017-04-25 22:41:51 +02:00
Filip Hrisafov
25401794b0 Add the workaround for Travis in the processor pom 2017-04-23 13:23:15 +02:00
Filip Hrisafov
63689e67a0 Make sure that surefire keeps the argline modified by jacoco 2017-04-23 13:08:47 +02:00
Filip Hrisafov
267c2e98f9 #993 Add support for disabling the generation of forged mapping methods 2017-04-20 23:37:16 +02:00
Filip Hrisafov
5fccc6c2d5 #1171 Add Travis CI (#1172) 2017-04-06 21:22:38 +02:00
Filip Hrisafov
bbff0c0349 #1164 Make sure that all import types of a Type are imported for the collection and map wrappers 2017-03-31 21:41:08 +02:00
Filip Hrisafov
fdf37cf451 #725 Flag the Annotation element with the wrong dateFormat 2017-03-30 19:18:57 +02:00
Filip Hrisafov
c465dd27c6 #1155 Field accessors should be considered when resolving nested target properties 2017-03-25 08:44:21 +01:00
Andreas Gudian
01d9997ed6 [maven-release-plugin] prepare for next development iteration 2017-03-16 20:33:20 +01:00
Andreas Gudian
daedc88425 [maven-release-plugin] prepare release 1.2.0.Beta2 2017-03-16 20:33:19 +01:00
navpil
fc8ded0dec #1103 Fix issue with recursive mapping throwing a StackOverflow 2017-03-16 20:00:05 +01:00
Filip Hrisafov
9881a8803c #1104 use unmapped target policy for forged name based mappings 2017-03-15 22:04:58 +01:00
sjaakd
e154452d53 #1126 Add new CollectionMappingStrategy TARGET_IMMUTABLE 2017-03-14 21:36:36 +01:00
Andreas Gudian
cab7596a47 #1130 Consider the right target type for object factory methods 2017-03-13 22:11:34 +01:00
Filip Hrisafov
57bf93bb84 #1092 Add github id next to contributers 2017-03-13 20:34:22 +01:00
Andreas Gudian
f7b6d91d5e #1124 Don't pass context parameters to forged methods for nested property mapping methods 2017-03-12 16:03:09 +01:00
Filip Hrisafov
d4c6250944 #1102 Add support for Auto forging of Enum properties 2017-03-12 15:34:46 +01:00
sjaakd
12f1cc0777 #1121 TypeMirror should not be used as hashCode base for Type 2017-03-08 22:17:20 +01:00
Gunnar Morling
86d05f64d2 #1119 removing superfluous method override 2017-03-02 21:30:18 +01:00
sjaakd
8fab3dd4e5 #1111 local variabele should not clash with loop variable 2017-03-02 20:16:41 +01:00
Filip Hrisafov
880ae56652 #1109 Add import for @Qualifier in the documentation 2017-03-01 22:15:52 +01:00
sjaakd
58992b8edf #1105 cleaning up MethodReference freemarker template 2017-02-26 11:39:14 +01:00
Gunnar Morling
8353f53ab9 #1101 Fixing confusing method name in test mapper 2017-02-26 10:02:49 +01:00
sjaakd
fa20d03051 #1065 @InheritReverseConfiguration from MappingConfig 2017-02-23 22:08:09 +01:00
Gunnar Morling
13c3d878d8 Updating link to ref guide 2017-02-22 20:31:19 +01:00
Filip Hrisafov
7d56a85dbd Fix checkstyle error 2017-02-21 21:48:30 +01:00
Filip Hrisafov
f654da2563 #1059 Add ftlvariable to the ftl files so we can have autocomplete with IntelliJ 2017-02-21 21:36:01 +01:00
Filip Hrisafov
0f6d5ff0f8 Fix checkstyle error 2017-02-21 21:35:04 +01:00
Filip Hrisafov
10aeb444f5 #1091 Map ANY_REMAINING Enum source to null 2017-02-21 20:43:19 +01:00
Andreas Gudian
3cc8972126 [maven-release-plugin] prepare for next development iteration 2017-02-20 20:58:14 +01:00
Andreas Gudian
520451bcd8 [maven-release-plugin] prepare release 1.2.0.Beta1 2017-02-20 20:58:12 +01:00
Sjaak Derksen
582bbe4412 #1057 documentation for Controlling forged name based bean mapping from root level with @Mapping 2017-02-20 19:21:15 +01:00
Filip Hrisafov
51e5976a7f #1001 Update documentation for the new automapping 2017-02-20 19:19:42 +01:00
Filip Hrisafov
d4b0f3324b #1057 Add some explanatory comments / Javadoc 2017-02-20 00:19:31 +01:00
Filip Hrisafov
3192345e33 #1057 Add source fixtures for tests 2017-02-20 00:19:31 +01:00
Filip Hrisafov
665f2571b6 #1057 Add forged named based parameter to distinguish between our methods that MapStruct has to create and methods that we create for the internal framework 2017-02-20 00:19:31 +01:00
Filip Hrisafov
f0646c6287 #1057 Add full support for controlling name based mapping from root level with @Mapping 2017-02-20 00:19:31 +01:00
Filip Hrisafov
378961fc53 #1057 Add ReportingPolicy to the BeanMapping
Use ReportingPolicy for explicitly ignoring unmapped target properties in
forged methods.
2017-02-20 00:19:31 +01:00
sjaakd
6f51cf4a8a #1057 Towards controlling name based mapping from root @Mapping 2017-02-20 00:19:31 +01:00
sjaakd
bdbee40dcf #1057 Add reproducer tests 2017-02-20 00:19:31 +01:00
Filip Hrisafov
8dbcc43a8e #1082 Do not generate an empty line after method start for NestedPropertyMappingMethod 2017-02-19 16:13:00 +01:00
Filip Hrisafov
9899504db9 #1073 Change NestedPropertyMappingMethod to not use name in its equality, but to use the Safe Properties 2017-02-19 11:50:52 +01:00
sjaakd
af8e70d84c Javadoc cleanup 2017-02-17 22:46:16 +01:00
Filip Hrisafov
8d8d1c37f2 Use static instance instead of always initialising the empty MappingOptions 2017-02-17 22:46:16 +01:00
Filip Hrisafov
c751100272 #1011 extract the grouping of the nested target properties out of the MappingOptions into its own class 2017-02-13 23:48:22 +01:00
Filip Hrisafov
106214cb9f #1011 extract the generation of the nested target properties mappings into a separate class 2017-02-13 23:48:22 +01:00
Gunnar Morling
5564c53f41 #1056 Making sure indentation level in formatting writer never goes below 0 2017-02-12 00:27:02 +01:00
Filip Hrisafov
40fc5612cb #1060 Use update methods if there are multiple source parameters 2017-02-10 19:57:41 +01:00
Filip Hrisafov
56ea9dd168 #1050 Use the getNull method from the Type instead of the getDefaultValue 2017-02-05 18:49:43 +01:00
Filip Hrisafov
c9a313ac15 #1050 Extract a common MappingMethod for the normal (non-enum / non-value) mapping methods that are used within MapStruct 2017-02-05 18:49:43 +01:00
Filip Hrisafov
79acfff9c3 #1050 remove duplicate properties which are already defined in the parent 2017-02-05 18:49:43 +01:00
Filip Hrisafov
9c30727262 #1061 Support for generating Mappers in the default package 2017-02-05 08:56:36 +01:00
Andreas Gudian
32bf03642c #983, #975 rephrase documentation of AfterMapping/BeforeMapping and document @Context usage 2017-02-02 21:57:26 +01:00
Andreas Gudian
ac03999170 #975 Allow calling BeforeMapping/AfterMapping methods directly on @Context params 2017-02-02 21:57:26 +01:00
sjaakd
1406c0b6db #1011 Using ForgedMethods to forge nested target mappings 2017-02-01 10:07:44 +01:00
sjaakd
12fcf7ce87 #1047 removing unneeded NPE check for source parameter for update method 2017-02-01 10:07:44 +01:00
Filip Hrisafov
b3cbfb8206 #1001 remove ForgedMethod from MappingMethods and directly create MappingMethods instead 2017-02-01 09:48:11 +01:00
Gunnar Morling
6e545347d0 #1045 Supporting mappers with generated source/target types by deferring their generation to a later round 2017-01-31 22:03:31 +01:00
Gunnar Morling
5e59f3484c #510 Adding experimental SPI for letting AST-modifying annotation processors such as Lombok tell us about future modifications 2017-01-31 22:02:29 +01:00
Gunnar Morling
754877cece #510 Adding experimental SPI for letting AST-modifying annotation processors such as Lombok tell us about future modifications 2017-01-31 18:22:52 +01:00
navpil
ef1c95ad1b #1001 Change meaningless names in MultipleForgedMethodTest to Dictionaries and Words to make test data easier to understand 2017-01-25 10:51:56 +02:00
navpil
5088aa062b #1001 Change TestMultipleForgedMethodsTest as suggested 2017-01-24 12:23:13 +02:00
navpil
32738251e3 #1001 Dotted error messages 2017-01-17 12:25:21 +02:00
Filip Hrisafov
ba20dc5700 #1005 Report an error if the resulting type in the BeanMappingMethod is abstract 2017-01-12 23:00:53 +01:00
sjaakd
0188dcbdcc #1001 auto mapping support for update methods 2017-01-12 06:57:28 +01:00
Filip Hrisafov
5cb80cbb97 #1012 rename new abstract builder and mapping methods; improve Javadoc 2017-01-10 22:52:32 +01:00
Filip Hrisafov
029368494b #1012 extract common builder for the StreamMappingMethods and IterableMappingMethod 2017-01-10 22:51:51 +01:00
Filip Hrisafov
090cfe3db2 #1012 extract common class between IterableMappingMethod and StreamMappingMethod 2017-01-10 22:51:51 +01:00
sjaakd
1ee4731752 #1027 do not consider Inherit(Inverse)Configuration in used mappers 2017-01-08 20:18:27 +01:00
sjaakd
a69627de66 #1013 Inherit(Reverse)Configuration must only consider abstract methods 2017-01-08 19:19:01 +01:00
Andreas Gudian
283fd8ebda Merge branch '1.1-master' 2017-01-08 14:55:00 +01:00
Andreas Gudian
4063bd2eca #1029 Don't show an error when explicitly ignoring read-only properties 2017-01-08 14:38:06 +01:00
Filip Hrisafov
6b07dda829 #962 Add support for mapping Java 8 Streams 2017-01-06 09:49:16 +01:00
Andreas Gudian
48d7963cca Merge branch '1.1-master' 2017-01-05 22:04:29 +01:00
Andreas Gudian
00a4ea2cfb #1032 Update license headers to 2017, fixing missing files. 2017-01-05 21:58:58 +01:00
Gunnar Morling
24acda3980 #1032 Updating year in one more place 2017-01-05 21:56:58 +01:00
Andreas Gudian
22b28f58db Merge branch '1.1-master' 2017-01-05 21:11:10 +01:00
Andreas Gudian
b02f8e5df5 #1032 Update license headers to 2017 2017-01-05 18:55:26 +01:00
Filip Hrisafov
ec6913618e #1007 Add additional generated code tests 2017-01-04 09:32:02 +01:00
Filip Hrisafov
8654d8f45a #1007 add base for comparing generated code to a fixed baseline 2016-12-30 19:03:45 +01:00
Filip Hrisafov
a2bd4a021f #965 fix wrong reference to NullValueMappingStrategy 2016-12-28 09:43:39 +01:00
sjaakd
4d3aaf15ff #285 JAXB object factory method selection for forged lists 2016-12-27 23:00:15 +01:00
sjaakd
3b84ff797c #1009 avoid including non used createDecimalFormat helper method 2016-12-25 23:34:00 +01:00
Andreas Gudian
44fe197d3b #975 Introduce @Context annotation for passing context parameters through generated mapping methods to custom methods 2016-12-25 11:05:58 +01:00
Filip Hrisafov
00b8ae01a1 #1014 do not generate FQN for extends/super bound Types 2016-12-22 23:54:50 +01:00
sjaakd
78db48f7cb #941 adapting more logical names for local variables 2016-12-21 22:02:19 +01:00
sjaakd
2fdd392e19 #941 adapting strategy naming of safe variable names 2016-12-21 22:02:19 +01:00
sjaakd
d1388c3a45 #941 undesired too postfixes in local variable names 2016-12-21 22:02:19 +01:00
Filip Hrisafov
ea6493d983 #657 Using bean mapping result types works when the map return type is not an interface 2016-12-20 23:31:57 +01:00
sjaakd
1f0533ca94 #996 refactor ArrayCopyWrapper 2016-12-20 23:07:15 +01:00
Filip Hrisafov
fc0f13a7a1 #999 make sure that the qualifiedName of the class is trimmed before doing any comparisons for import check 2016-12-20 00:06:12 +01:00
Andreas Gudian
79f87e8833 #975 Refactor method-matching to unify selection and rendering of mapping method, factories and lifecycle methods 2016-12-19 22:36:12 +01:00
sjaakd
46363028bd #988 Strange enters in templates 2016-12-19 21:59:47 +01:00
sjaakd
70896245d7 #973 Setter and Update wrapper refactoring and cleanup 2016-12-19 21:59:47 +01:00
sjaakd
d398618aa5 #60 automapping removing commented-out-code and copyright 2016-12-19 21:45:14 +01:00
navpil
81ce66044f #60 automapping 2016-12-19 21:45:14 +01:00
Filip Hrisafov
228c1f9f1b #557 add Javadoc for the Accessor 2016-12-19 18:51:04 +01:00
Filip Hrisafov
f94990270f fix a typo in the documentation 2016-12-06 22:37:30 +01:00
sjaakd
81a4cb360d #981 Refactoring, move SourceRHS init to start of property build. 2016-12-05 22:17:34 +01:00
Filip Hrisafov
0ec9729801 #557 Add documentation about using fields as read/write accessors 2016-12-04 23:39:51 +01:00
Andreas Gudian
e8c8428945 Adding Pascal to the list of contributors 2016-12-04 16:17:36 +01:00
Pascal
075e763556 #469 Consider return values of BeforeMapping/AfterMapping methods
This allows to handle cycles in object graphs, as demonstrated in the
test case CallbacksWithReturnValuesTest
2016-12-04 16:15:19 +01:00
Filip Hrisafov
746f49fe3d #557 Provide a way to use direct field mappings within mapstruct 2016-12-03 21:57:13 +01:00
Filip Hrisafov
bfad22edf7 Merge branch '1.1-master' 2016-12-02 22:58:43 +01:00
Filip Hrisafov
a20b077150 #980 Add tests for the Strings class 2016-12-02 22:56:15 +01:00
Filip Hrisafov
3dac7d9f41 #978 make sure that the safe variable name does not contain dots in it, if it does split it and join and camelize the parts 2016-12-02 22:56:15 +01:00
Andreas Gudian
050c398da6 #966 Avoid missing newlines between methods and multiple newlines (generally) by adding a checkstyle rule, fixing current incarnations. 2016-12-01 21:52:58 +01:00
Andreas Gudian
ce02463d9c Adding Remo to the list of contributors 2016-12-01 21:18:26 +01:00
Remo
35b8972d76 #824 Target Bean Factory
Introduced @ObjectFactory annotation to distinguish between factory and
mapping methods. Until now this was decided based on the lack of
parameters. @ObjectFactory gives a factory access to source object by
defining them as parameters.
2016-12-01 10:38:37 +01:00
Filip Hrisafov
03e4840f10 Merge branch '1.1-master' 2016-11-30 01:38:30 +01:00
Filip Hrisafov
980acba2ac #971 Make sure that an Iterable or Map MapingMethod are equal if their source parameters are from the same type 2016-11-30 01:37:39 +01:00
Andreas Gudian
6ed88b019f Merge branch '1.1-master' 2016-11-29 21:13:12 +01:00
Maxim Kolesnikov
9a537753c2 Fix a few documentation errors. 2016-11-29 21:08:54 +01:00
sjaakd
afaca926ae #899 Refactoring adderwrapper, simplifying SourceRHS. 2016-11-27 22:47:17 +01:00
sjaakd
488eae2de2 #968 removing strange enters and spaces in formatting. 2016-11-26 17:38:10 +01:00
Andreas Gudian
f3e489bc8c Merge branch '1.1-master' 2016-11-18 23:00:34 +01:00
Andreas Gudian
7b5a2331a8 Reduce cache lifetime of latest-version badge from 30d to 1h 2016-11-18 23:00:21 +01:00
Andreas Gudian
15dfcc590b Merge branch '1.1-master' 2016-11-18 22:26:37 +01:00
Andreas Gudian
81d4bd3d51 Update latest stable version in readme.md 2016-11-18 22:14:36 +01:00
Andreas Gudian
33546cd7d5 Merge branch '1.1-master' into master, update latest stable version in readme.md 2016-11-18 22:10:27 +01:00
Andreas Gudian
62721b207b [maven-release-plugin] prepare for next development iteration 2016-11-18 21:45:42 +01:00
Andreas Gudian
b0b816f552 [maven-release-plugin] prepare release 1.1.0.Final 2016-11-18 21:45:41 +01:00
sjaakd
dc61079793 Merge branch '1.1-master' into master 2016-11-14 23:31:33 +01:00
sjaakd
4c4a9ea934 #954 cleanup 2016-11-14 22:49:47 +01:00
sjaakd
9186978e1f #954 Explicit set to null NOT for NVCS.ALWAYS and presence-checkers 2016-11-14 22:49:31 +01:00
sjaakd
48181ae09e #913 New property mapping collection handling, unit test extension 2016-11-14 22:49:08 +01:00
Andreas Gudian
f22eb766f2 Merge branch '1.1-master' into master 2016-11-14 22:32:46 +01:00
sjaakd
71a6ef4836 #955 Import type param type when call to upd. method for coll.impl type 2016-11-14 22:28:16 +01:00
Andreas Gudian
44f7070e75 Update version on master branch to 1.2.0-SNAPSHOT 2016-11-07 21:08:42 +01:00
Andreas Gudian
d83be86994 [maven-release-plugin] prepare for next development iteration 2016-11-07 20:52:04 +01:00
Andreas Gudian
4eb8fae8df [maven-release-plugin] prepare release 1.1.0.CR2 2016-11-07 20:52:03 +01:00
sjaakd
1fa0c4aa3b #913 New property mapping collection handling 2016-11-06 20:48:10 +01:00
Gunnar Morling
52f48fe1da #949 Adding example of Ant usage to reference guide 2016-11-05 16:03:41 +01:00
Andreas Gudian
4832369148 #892 If multiple setters exist, don't override the setter if it doesn't match the property getters type. 2016-11-02 22:27:59 +01:00
Gunnar Morling
a928ff56d7 #945 Adding clarification that Java 8 is needed for default methods 2016-11-01 19:08:06 +01:00
Dominik Gruntz
fff7457286 #945 Updates mapstruct-reference-guide: Revives caption
Caption to example 17 got lost (due to a missing line). Adds the missing line in front of
        .Conversion from BigDecimal to String
    so that this caption is printed as caption again.
2016-11-01 19:04:05 +01:00
Dominik Gruntz
422821f3cf #945 changes s.getLongProp() to s.getLongProperty()
In the mapping no source name is specified for this property, so the
        name longProperty is used
2016-11-01 19:04:03 +01:00
Dominik Gruntz
81b4535aad #945 fixes typo 2016-11-01 19:03:40 +01:00
Dominik Gruntz
5de2750740 #945 Documentation: Converts an item to a caption
In section 6 the caption is written as
           . Generated collection mapping methods
        and does therefore appear as an enumeration instead of a caption.
2016-11-01 19:03:37 +01:00
Dominik Gruntz
65ffa8891a #945 Extension of chapter 3.2
This commit extends the description of section 3.2 with the possibility
to declare custom mapping methods as default methods in the interface
directly.
2016-11-01 19:02:31 +01:00
Gunnar Morling
648dcaf0dc #787 Adding review remark 2016-10-30 18:34:04 +01:00
Gunnar Morling
9f76af7e3d #787 Giving some love to the readme.md 2016-10-29 12:13:08 +02:00
Gunnar Morling
ba28a64986 Minor doc update 2016-10-29 09:17:08 +02:00
Maxim Kolesnikov
b2e7cb3e16 Fix a few documentation errors. 2016-10-29 09:09:50 +02:00
Gunnar Morling
8d5c25ebc2 #900 Adding note on JDK 9 to documentation 2016-10-28 22:29:06 +02:00
Andreas Gudian
f8bb31f98d #900 Use "@Generated" only when it's available on the classpath. 2016-10-28 20:26:13 +02:00
sjaakd
4297c0cd72 #689 Documentation for Joda types to XmlGregorianCalendar 2016-10-25 21:48:08 +02:00
sjaakd
c105630379 #689 Moving test to right spot and making it Locale independent. 2016-10-25 21:48:08 +02:00
sjaakd
a1131e68c9 #689 Joda LocalTime to XmlGregorianCalendar built in and vice versa 2016-10-25 21:48:08 +02:00
sjaakd
aec5922bd0 #689 Joda LocalDate to XmlGregorianCalendar built in and vice versa 2016-10-25 21:48:08 +02:00
sjaakd
e43b00d29c #689 Joda LocalDateTime to XmlGregorianCalendar built in and vice versa 2016-10-25 21:48:08 +02:00
sjaakd
13395f5958 #689 Joda DateTime to XmlGregorianCalendar built in and vice versa 2016-10-25 21:48:08 +02:00
sjaakd
b653c6b464 #931 nested forged methods return wrapped type when target is an object 2016-10-23 22:23:57 +02:00
Gunnar Morling
21750ce898 #852 Adding Peter Larson to copyright.txt 2016-10-23 21:01:33 +02:00
Gunnar Morling
a09e8c119a #852 Updating documentation 2016-10-23 21:00:58 +02:00
Gunnar Morling
c64919829a #852 Adding explicit conversion for LocalDate <> XMLGregorianCalendar 2016-10-23 21:00:57 +02:00
Peter Larson
e13696172e #852 Expanding converters to cover java 8 LocalDate to java.util.Date 2016-10-23 21:00:47 +02:00
sjaakd
c36f4577ab #921 Avoid generation of duplicate local variable name 2016-10-20 21:03:42 +02:00
Andreas Gudian
d94d5857ce #919 Fix compilation error in map-mapping methods with non-generic maps as source 2016-10-10 20:04:44 +02:00
Andreas Gudian
4ab3c2d537 #920 Fix link to JSR 269 in readme.md 2016-10-09 16:21:16 +02:00
Gunnar Morling
7b0079c6be #915 Adding debug information to class files created during tests 2016-09-29 22:24:18 +02:00
Gunnar Morling
2bbc733932 #858 Deleting unused class 2016-09-29 19:20:14 +02:00
Filip Hrisafov
fb286e3d39 #858 Update documentation with java.sql.* implicit type conversions 2016-09-29 19:13:13 +02:00
Gunnar Morling
75e3fe1e72 #909 Adding comment on workaround 2016-09-29 17:56:20 +02:00
Andreas Gudian
7bd1ed6180 #909 Avoid using 'values' as parameter name to work around a supsected issue in Freemarker. 2016-09-26 22:46:05 +02:00
Andreas Gudian
e1bada14fe Adding Stefan May to the list of contributors 2016-09-21 22:42:59 +02:00
Andreas Gudian
f822000f92 #853 Minor adjustments after review 2016-09-21 22:42:59 +02:00
stefan.may
1be3c4dbaa #853 Enable support for Iterable / Map classes which are not generic, like they are generated by JAXB (e.g. public class StringList extends List<String>) 2016-09-21 22:42:58 +02:00
Gunnar Morling
9753fdc17a #765 Omitting "return" key word when returning from decorated void method 2016-09-21 22:26:43 +02:00
Filip Hrisafov
ab159ed86a remove java.sql.Time and java.sql.Timestamp FQN 2016-09-21 19:55:21 +02:00
Filip Hrisafov
5fd0c3e3d4 remove builtin methods; remove test which is not needed anymore 2016-09-21 19:55:20 +02:00
Filip Hrisafov
c5dc2ccb92 use SimpleConversion for java.sql mappings 2016-09-21 19:55:20 +02:00
Filip Hrisafov
f88fd6ece9 #858: Add built in methods for java.sql.Time, java.sql.Timestamp and java.sql.Date 2016-09-21 19:55:20 +02:00
Andreas Gudian
5927431791 #895 Fix generating forged iterable methods for mapping multi-dimensional Array types 2016-09-17 11:58:27 +02:00
sjaakd
371e0884a4 #891 Cleanup and renaming of Direct and AssignmentFactory 2016-09-16 23:05:37 +02:00
sjaakd
750af10900 #891 Implementation and unit test 2016-09-16 23:05:37 +02:00
Andreas Gudian
ecd6411f93 Adding Pavel Makhov to the list of contributors 2016-09-15 21:26:46 +02:00
Pavel Makhov
c2fc030217 Update mapstruct-reference-guide.asciidoc
Fix few typos
2016-09-13 16:27:04 -04:00
Andreas Gudian
af68fcf616 [maven-release-plugin] prepare for next development iteration 2016-09-07 20:27:36 +02:00
Andreas Gudian
9ed807196e [maven-release-plugin] prepare release 1.1.0.CR1 2016-09-07 20:27:34 +02:00
Andreas Gudian
13d54320a7 #888 Add configuration snippets for Gradle to reference guide and to the readme. 2016-09-06 22:09:29 +02:00
sjaakd
c8a9592bc9 #707 Automatic generation of iterable method if element mapping method(s) are qualified 2016-09-06 21:51:52 +02:00
sjaakd
9996fc66ab #878 disable AcessorNamingStrategy#getCollectionGetterName from SPI 2016-09-05 21:28:14 +02:00
Andreas Gudian
e57f4c9e5c Rename o.m.a.i.option.ReportingPolicy to o.m.a.i.prism.ReportingPolicyPrism and add missing prism enum tests. 2016-09-04 12:32:22 +02:00
Andreas Gudian
8071723bae #880 Fix override behaviour for componentModel and unmappedTargetPolicy. 2016-09-02 23:17:25 +02:00
sjaakd
c73d007fc8 #865 Collection NPE check for a calling update method. 2016-08-31 22:29:45 +02:00
sjaakd
ccb0f34575 #849 Missing imports for generic type parameters on Iterable and Maps 2016-08-30 22:56:51 +02:00
sjaakd
e793853fc8 #843 Inefficient code generated when using NullValueCheckStrategy.ALWAYS icw nested source properties. 2016-08-30 22:37:33 +02:00
sjaakd
a5a82cf5f1 #700 Fixing enum constants and adding unit test. 2016-08-30 21:55:21 +02:00
sjaakd
824fb993b5 #707 Document to always use RetentionPolicy.CLASS in custom qualifier annotations. 2016-08-30 21:52:46 +02:00
sjaakd
fd077047ca Removing javadoc warnings in build 2016-08-30 21:17:41 +02:00
sjaakd
daddb255dd #832, #866 Documentation update on the SPI, adding DefaultAccessorNamingStrategy javadoc, fixing responsibility issue 2016-08-30 21:17:41 +02:00
Andreas Gudian
d99590306e #787 Enhance readme to use maven-compiler-plugin and add some badges. 2016-08-30 14:37:48 +02:00
Andreas Gudian
fd17681674 Adding Filip Hrisafov to the list of contributors 2016-08-27 13:14:22 +02:00
Filip Hrisafov
cf88cf9e92 #860 switch to using assertj instead of FEST assertions 2016-08-27 13:10:42 +02:00
Andreas Gudian
c05d44845d #842 Use project.version as MapStruct version in the documentation 2016-08-24 22:35:15 +02:00
Andreas Gudian
7d967578ea Adding Markus Heberling to the list of contributors 2016-08-24 22:21:33 +02:00
Andreas Gudian
126623e626 #855 Fix property order when using dependsOn 2016-08-24 22:19:18 +02:00
Markus Heberling
5d0bc08e2e #855 Show incorrect ordering of properties 2016-08-24 22:17:41 +02:00
sjaakd
75021ada1b #846 Exclude updates methods from suitable constructor check 2016-08-13 22:46:31 +02:00
Andreas Gudian
1b6b5f18bb [maven-release-plugin] prepare for next development iteration 2016-07-22 21:20:25 +02:00
Andreas Gudian
e23056c9dd [maven-release-plugin] prepare release 1.1.0.Beta2 2016-07-22 21:20:24 +02:00
sjaakd
dd5ddc854b #836 removing reverse mapping parameter check. 2016-07-21 11:41:55 +02:00
sjaakd
3d43d022f4 #838 check for suitable constructors when reversing 2016-07-21 10:58:14 +02:00
sjaakd
70ba92b229 #389 Nested target properties 2016-07-20 22:00:21 +02:00
Sjaak Derksen
80383dd122 #833 specializing missing prop message for non existing write accessor (#834) 2016-07-17 17:00:42 +02:00
Andreas Gudian
53e542c9bc #828 Fix NoClassDefFoundError when running in Eclipse Neon (4.6) (#831) 2016-07-08 07:23:38 +02:00
sjaakd
23ebd273c8 #669 Documentation update for source presence checker and nullValueCheckStrategy 2016-07-06 23:11:04 +02:00
sjaakd
e725b9a2c6 #669 Making 'haxXYZ' the default presenceChecker 2016-07-06 20:43:36 +02:00
sjaakd
b1f03689d9 #669 rework into sourcepresencecheck SPI and nullvaluecheckstrategy 2016-07-05 22:50:10 +02:00
seanjob
1af4441d2d #669 ispresentcheck and NULL check implementation 2016-07-05 22:50:10 +02:00
Gunnar Morling
c47fd95d04 #801 Trying to load mapper implementation types via the mapper interface's loader first 2016-07-05 22:24:02 +02:00
Andreas Gudian
051177e409 #825 Add @WithServiceImplementation annotation in testutil to register SPI implementations in processor tests. 2016-07-05 20:51:24 +02:00
Andreas Gudian
1e6b81176d Fix typo in documentation. 2016-06-30 22:21:38 +02:00
Andreas Gudian
8bee368942 #27 Add OSGi metadata to manifests of mapstruct.jar and mapstruct-jdk8.jar. 2016-06-29 22:14:23 +02:00
Andreas Gudian
b9bccdb225 #805 use basic ASCII chars in the javadoc ASCII art tables 2016-06-29 22:14:23 +02:00
sjaakd
4ff0676c61 #212 regression fix 2016-06-23 22:49:22 +02:00
sjaakd
13dbc3cccf #212 reproducer 2016-06-23 22:48:41 +02:00
sjaakd
3700052cc6 #679 Adding testcases, helpermethods for decimalconversion, doc update 2016-06-15 23:34:48 +02:00
cliedeman
607d0fd6f0 Implemented Feature from Issue #679: Support of numberFormat for Number to String mapping 2016-06-07 22:16:04 +02:00
Andreas Gudian
d74f73aa2d [maven-release-plugin] prepare for next development iteration 2016-03-16 20:48:00 +01:00
Andreas Gudian
deacfc2c6a [maven-release-plugin] prepare release 1.1.0.Beta1 2016-03-16 20:47:59 +01:00
Andreas Gudian
ee2ff03c5b Update documentation version to 1.1.0.Beta1 and skip deployment of the documentation pom. 2016-03-16 20:44:32 +01:00
Gunnar Morling
2b0f5ee3e8 #769 Expanding note on M2E annotation processing set-up 2016-03-16 20:01:06 +01:00
Gunnar Morling
d4eb3fe290 #769 Updating set-up description to make use of Maven compiler plug-in 2016-03-16 20:01:06 +01:00
sjaakd
d59873d923 Fixing some general javadoc issues. 2016-03-15 22:20:10 +01:00
sjaakd
e15b873b9a #784 Javadoc issue 2016-03-15 22:20:10 +01:00
sjaakd
d8402a7df2 #784 Named should follow Qualifier strategy. 2016-03-15 22:20:10 +01:00
Andreas Gudian
b7450da585 #775 Fix mapping method type matching for lower-bounded target type. 2016-03-15 22:02:33 +01:00
Andreas Gudian
4c1d7a7a19 #775 Allow creation of forged mapping method for Iterable target type 2016-03-15 22:02:32 +01:00
sjaakd
ae4d0f77e1 #749 Introduction of @ValueMapping, @ValueMappings 2016-03-15 21:19:55 +01:00
Andreas Gudian
9b2145c6a8 #779 Allow to select only one compiler in a processor test class, but make the config-annotation deprecated to empasise that it's only to be used temporarily during debugging. 2016-03-13 20:49:59 +01:00
Andreas Gudian
c595bd72e3 Fix some compiler warnings. 2016-03-13 20:47:28 +01:00
Andreas Gudian
c671692cd0 #770 Update retention-policy of custom qualifier annotations in docs and tests to CLASS. 2016-03-07 19:15:50 +01:00
Gunnar Morling
27aa40c0ec #768 Consistently using Type#getImportTypes() for determining imported types 2016-03-07 19:14:00 +01:00
sjaakd
18912727ca #761 fixing cloudbees issue. 2016-02-20 22:31:07 +01:00
sjaakd
15b6afef58 #761 using fully qualified names in javadoc for conflicting annotations 2016-02-20 22:21:16 +01:00
Gunnar Morling
5e88dae8ce #750 Further expanding comment 2016-02-20 11:42:47 +01:00
sjaakd
e039c74c2a #750 Documentation update for @Named 2016-02-19 22:48:20 +01:00
sjaakd
d83d8b4102 #750 Refactoring, moving selection parameters to common SelectorParameters, repair 2016-02-16 23:14:13 +01:00
sjaakd
6a5e2a79e4 #750 Refactoring, moving selection parameters to common SelectorParameters 2016-02-16 21:16:04 +01:00
sjaakd
c1341d4fe0 #750 Unit Test of @Named annotation 2016-02-16 21:10:31 +01:00
sjaakd
faedebc119 #750 Initial implementation of @Named annotation 2016-02-16 21:10:31 +01:00
sjaakd
bb1ccac434 #750 Introducing the @Named annotation 2016-02-16 21:10:30 +01:00
Gunnar Morling
9d377106d3 #754 Moving ToC to the right 2016-02-15 00:23:07 +01:00
Gunnar Morling
946d45eebe #754 Improving wording in Preface, putting guide under http://creativecommons.org/licenses/by-sa/4.0/ 2016-02-15 00:23:07 +01:00
Gunnar Morling
6143d920cf #754 Adding reference guide to distribution; Removing some dependencies between HTML and PDF executions 2016-02-15 00:23:07 +01:00
Gunnar Morling
6d87e2525d #754 Re-organizing some sections to reduce number of top-level chapters 2016-02-15 00:23:07 +01:00
Gunnar Morling
da5274ea54 #754 Moving qualifier section to conversion chapter 2016-02-15 00:23:07 +01:00
Gunnar Morling
650a53318e #754 Avoiding numbers in section ids 2016-02-15 00:23:07 +01:00
Gunnar Morling
652395d9d5 #754 Initial conversion of reference guide to AsciiDoc 2016-02-15 00:23:07 +01:00
Andreas Gudian
be2bf249d9 Add ZonedDateTime/Calendar test cases to BuiltInTest, remove obsolete test and reconfigure the test class to avoid unnecessary re-compilations. 2016-02-13 22:25:39 +01:00
Andreas Gudian
eb99d7b1ef #746 Add missing import for TimeZone in ZonedDateTimeToCalendar 2016-02-09 20:18:25 +01:00
Gunnar Morling
9a4738950f #634 Adding test case for mapper with generic super type 2016-02-07 19:50:28 +01:00
Gunnar Morling
eeb36239c4 #634 Renaming test package 2016-02-07 19:50:28 +01:00
Gunnar Morling
8a28f12999 #634 Using DeclaredType instead of TypeElement when resolving property accessors of mapped bean types; That way accessor parameter/return types referring to type parameters of the bean will be resolved correctly 2016-02-07 19:50:27 +01:00
Gunnar Morling
4997f3f292 #634 Consolidating determination of target type in property mapping builders 2016-02-07 19:50:27 +01:00
sjaakd
22f1e71519 #740 baseline update to version 2.19.1 of Surefire plugin 2016-02-04 20:54:40 +01:00
Gunnar Morling
4a74ee8f6c #732 Properly copying enum sets 2016-02-02 21:51:36 +01:00
Andreas Gudian
f93487f288 #664 Adding Sam to copyright.txt 2016-02-02 20:20:47 +01:00
Andreas Gudian
b09f32f926 #664 Add test to verify that jsr330 mappers are annotated with @Singleton and @Named. 2016-02-02 20:18:25 +01:00
Sam Wright
5ede0e91db #664 Annotate mapper implementations with @Singleton when using jsr330. 2016-02-02 19:52:24 +01:00
Gunnar Morling
f0559fca43 #729 Adding Oliver to copyright.txt 2016-02-02 19:31:10 +01:00
Gunnar Morling
0a41360acf #729 Some clean-up 2016-02-02 19:31:10 +01:00
Gunnar Morling
79ececf83e #729 Adjusting license header 2016-02-02 19:19:00 +01:00
Oliver Ehrenmüller
4101ed86c9 #729 added unittest for mapping property of collection to primitive 2016-02-02 09:01:49 +01:00
Oliver Ehrenmüller
e42788ece2 #729 Fix trying to resolving constructor on primitive types (correct formatting) 2016-02-01 13:10:44 +01:00
Oliver Ehrenmüller
39158f649f #729 Fix trying to resolving constructor on primitive types 2016-02-01 13:07:59 +01:00
Gunnar Morling
01322e0a9c #726 Adding Vincent to copyright.txt 2016-01-19 19:53:51 +01:00
Vincent Alexander Beelte
f84938f46e find information in XmlElementRef annotations to match it against XmlElementDecl to implement #726 2016-01-19 19:08:38 +01:00
Gunnar Morling
34aceff5f8 #723 Updating year in license headers 2016-01-16 18:00:09 +01:00
Andreas Gudian
1ae3d07388 #701 Update checkstyle version and fix several previously undetected issues in our code (mostly missing whitespaces and redundant modifiers) and in the generated code (superflous whitespaces before commas)
Requrires update of guava and cdi-weld do to dependency convergence.
2016-01-02 17:50:09 +01:00
Andreas Gudian
5831e824e1 Organize imports to put static imports back on top. 2015-12-18 23:08:56 +01:00
Andreas Gudian
c0b005429a #691 Create an integration test that compiles all test mappers from the processor module with JDK 6/7/8/9, Eclipse JDT on language levels 1.6/1.7/1.8. 2015-12-18 22:01:40 +01:00
Gunnar Morling
8b35c63e9a #693 Typo fix 2015-12-18 21:31:31 +01:00
Gunnar Morling
c59ef3ab7a #693 Renaming test entities in generics test for the sake of easier understanding 2015-12-18 21:31:31 +01:00
Gunnar Morling
55b74ae384 #710 Deferring processing of mappers with incomplete source/target types to a later processing round 2015-12-17 23:53:20 +01:00
Gunnar Morling
03bf027858 #710 Excluding tools dependency from CheckStyle 2015-12-17 23:53:20 +01:00
Gunnar Morling
1e318e3405 [maven-release-plugin] prepare for next development iteration 2015-11-25 22:56:43 +01:00
Gunnar Morling
8fb0424326 [maven-release-plugin] prepare release 1.0.0.Final 2015-11-25 22:56:40 +01:00
Gunnar Morling
a45611315a Updating readme.md prior to 1.0.0.Final release 2015-11-25 22:26:45 +01:00
Andreas Gudian
7c2b4c9541 #698 Fix missing import for enums in case of default values. 2015-11-25 19:56:42 +01:00
Andreas Gudian
dde84306ab #644 Only delegate to the Eclipse-specific workaround when the compiler is actually identified as Eclipse JDT 2015-11-16 20:32:41 +01:00
Andreas Gudian
76603416e7 #644 Basically reverting changes made for #127, with a fix for handling super-bounds in JDK (failed after wrapping Types in TypesDecorator). Moved most of the logic of Types.getTypeBounds() to TypeFactory. 2015-11-13 22:06:53 +01:00
Andreas Gudian
874a9b3a52 #644 Add more elaborate test case for inheritance with generics with multiple overlapping interfaces 2015-11-13 22:05:22 +01:00
Andreas Gudian
e4bbfdaaa6 #688 Fix handling of overridden methods in adjacent interface hierarchies. 2015-11-13 22:04:32 +01:00
Andreas Gudian
fc660e2c02 #687 Fix detection of source property type in case the mapping is specified via annotation 2015-11-13 22:04:31 +01:00
Andreas Gudian
8a3d5418df #644 Workaround for problems with the Eclipse implementation of asMemberOf. Refactored SpecificCompilerWorkarounds to be primarily used through a decorated variant of Types that is now used throughout MapStruct. 2015-11-13 22:04:31 +01:00
Andreas Gudian
2291f2dedd #667 Fix execution of single test methods in some cases. 2015-11-09 22:54:48 +01:00
Andreas Gudian
58e7079ad5 #667 Add/Fix javadoc, clarify supported modes of concurrency. 2015-11-09 22:54:48 +01:00
Andreas Gudian
aba26328ba #667 Run all processor tests with both the JDK compiler and the Eclipse compiler.
All generated sources and compilation results are kept in a new directory structure, making manual inspection easier, and also simplifying parallel test-class execution.
2015-11-09 22:54:47 +01:00
Andreas Gudian
af9b54fa4f #684 Update joda-time to fix an incompatibility with JDK 1.8.0_60 and later, and reverted changes to JodaConversionTest from commit feb5e2f13b0eea3027000cc7f03d6b63690505c5. 2015-11-07 20:28:45 +01:00
Gunnar Morling
18c03a328d #681 Using UTC for Date/JavaLocalDate conversion in both directions 2015-11-06 19:19:34 +01:00
Andreas Gudian
1f091c35e2 #660 Fix custom package / implementation name when using componentModel="default" with abstract classes 2015-10-24 20:55:45 +02:00
Andreas Gudian
82ab85d3bc #642 Simplify handling of toolchains file by autodetecting which JDKs are configured there. 2015-10-22 20:18:27 +02:00
Andreas Gudian
feb5e2f13b Fix test failing on Windows 10 with JDK 1.8.0_60 2015-10-22 20:17:41 +02:00
sjaakd
11a03e54ca #640 - applying Mapper or Mapperconfig NullValueMappingStrategy to forged methods 2015-09-22 23:08:37 +02:00
sjaakd
b816469537 #631 - adding error message for generic type variables as source / target / result 2015-09-14 21:38:32 +02:00
sjaakd
18532ace8c #636 - adapt integration test for default and static interface methods (Java8) to eclipse compiler problem 2015-09-14 09:09:26 +02:00
sjaakd
45db85a7be #636 - refinement of solution java8 default and static interface methods 2015-09-14 09:06:22 +02:00
Ivo Smid
a15a67ff47 #636 - fix - default methods (Java 8) do not work anymore 2015-09-14 09:02:33 +02:00
Andreas Gudian
c43b495863 [maven-release-plugin] prepare for next development iteration 2015-08-27 10:58:55 +02:00
Andreas Gudian
7e7285ac49 [maven-release-plugin] prepare release 1.0.0.CR2 2015-08-27 10:58:55 +02:00
Andreas Gudian
5a2e1e3f87 Update readme.md with latest version information 2015-08-27 10:52:01 +02:00
Andreas Gudian
72a7bdbb83 #592 Improve @DecoratedWith javadoc 2015-08-23 21:46:06 +02:00
Andreas Gudian
bce6271f7a #625 Don't search for factory methods when generating update-methods. Rephrase error message for ambiguous factory methods. 2015-08-23 18:36:52 +02:00
Andreas Gudian
590363cf2f #592 Fix Decorator-support for component model 'spring' and 'jsr330', extend decorator integration-tests, add examples to @DecoratedWith javadoc 2015-08-23 16:40:54 +02:00
Andreas Gudian
4eaacbcfe6 592 allow to use all test-scope dependencies in the on-the-fly compilation classpath 2015-08-23 16:38:28 +02:00
Andreas Gudian
71f4a4b2ca #626 Remove blank lines before closing brackets 2015-08-17 23:02:16 +02:00
Andreas Gudian
2c2f69b0d3 #626 Remove doubled blank lines on Windows 2015-08-17 22:10:44 +02:00
Andreas Gudian
9ccc9726ff Adding Christophe to the list of contributors 2015-08-14 21:14:17 +02:00
Andreas Gudian
6238e21247 #472 Fix typo in javadoc 2015-08-14 21:03:33 +02:00
Christophe Labouisse
29f720b35e #472, #556 Make implementation package and name configurable
- Add `implementationName` & `implementationPackage` to `@Mapper` and
`@MapperConfig'

- Generate a file in `META-INF/services` when a custom name or package
has been configured

- `Mappers` use `ServiceLoader` first in order to get a mapper's
  implementation before falling back to the former method

- Change the `MapperServiceProcess` behaviour to return `default` rather
  than `null` when no component model is defined
2015-08-14 21:03:33 +02:00
Andreas Gudian
9578f9b452 #588 Extend test to verify that #588 was actually fixed with the previous commit 2015-08-13 20:47:11 +02:00
Andreas Gudian
a85168f298 #618 Improve detection of unspecified annotation attributes and remove all "DEFAULT"/"default" values from annotations and enums that were previously only created to detect if a value was assigned or not. 2015-08-13 20:38:43 +02:00
Ivo Smid
44037172fc Utf-8 typo 2015-08-13 09:06:01 +02:00
Andreas Gudian
5e97bba7d1 Adding Mustafa to the list of contributors 2015-08-13 00:00:36 +02:00
Andreas Gudian
2a385c0ec8 #600 Improve generated assignment code when using default-values, enhance javadoc a little and remove unused attribute in PropertyMapping 2015-08-12 23:58:56 +02:00
luxmeter
964f676af6 #600 added defaultValue feature 2015-08-12 23:58:56 +02:00
Andreas Gudian
b0b2f51331 Adding Ivo to the list of contributors 2015-08-12 19:05:47 +02:00
Ivo Smid
60caf959e3 603 - Java 8 - Cant use static method on interface with decorators. 2015-08-12 12:58:21 +02:00
Andreas Gudian
e177f25d63 #604 Add import for property target type when using an update-method and no factory method is used to create a new instance 2015-08-09 12:36:48 +02:00
Andreas Gudian
30c8b1eec0 #590 Change test to not depend on un-supported String<->StringBuilder conversion 2015-08-09 12:23:36 +02:00
Andreas Gudian
5217e67f8d #590 Update methods are not supported for "method-and-conversion" methods (can currently cause NullPointerExceptions) 2015-08-09 12:23:36 +02:00
Andreas Gudian
1d1b215a93 #596 Add null-check on source for update-method invocations and set target property to null, if source is null 2015-08-09 12:10:10 +02:00
Andreas Gudian
abecb0d888 #580 Add null-check for mapped -> type-converted property mapping.
At least our built-in mapping methods return null for null input, which would break the type-conversion.
2015-08-09 12:10:10 +02:00
VGT
64dd46c354 #581 Prevent multiple imports of similar simple class name from different packages. 2015-07-02 22:44:42 +02:00
Andreas Gudian
2d686003c8 #576 Fix assignability check for @MappingTarget parameters in BeforeMapping/AfterMapping methods 2015-06-28 11:44:39 +02:00
Andreas Gudian
264a8f65af #574 determine property type from getter/setter methods only in combination with ExecutableType (i.e. using asMemberOf to determine the type with any generics being resolved) 2015-06-28 11:29:45 +02:00
Gunnar Morling
a35cf3c16d Adding Remko Plantenga to copyright.txt 2015-06-27 10:51:49 +02:00
Andreas Gudian
18dccf15da Adding Tomek to copyright.txt 2015-06-26 21:22:29 +02:00
VGT
b4bce14d6a #577 Improve type parameters equality check. 2015-06-26 20:43:20 +02:00
Gunnar Morling
33e6822694 [maven-release-plugin] prepare for next development iteration 2015-06-03 23:19:10 +02:00
Gunnar Morling
ee6c392870 [maven-release-plugin] prepare release 1.0.0.CR1 2015-06-03 23:19:10 +02:00
Gunnar Morling
7992624d84 Updating readme.md prior to 1.0.0.CR1 release 2015-06-03 23:16:45 +02:00
Gunnar Morling
3eab5a4f48 Making sure the right JavaDoc plug-in version is used during releases 2015-06-03 22:44:21 +02:00
Gunnar Morling
daaa99d143 #272 Allowing to inject decorated mapper in Spring without qualifier 2015-06-03 22:06:08 +02:00
Gunnar Morling
2ad77b5aa0 #272 Adding line breaks at end of files 2015-06-03 22:03:16 +02:00
sonata82
b37a1d24d9 #272 Basic decorator implementation for CDI and Spring 2015-06-03 22:03:16 +02:00
sjaakd
174c53cb48 #487 iterable and map update method selection 2015-05-29 23:26:56 +02:00
Andreas Gudian
c8e9f91037 #203 Move .ftl files into subdirectories representing the package path 2015-05-29 20:14:52 +02:00
Andreas Gudian
1baf8edc0a #548 Move all packages except of "spi" under "org.mapstruct.ap.internal" 2015-05-29 20:08:57 +02:00
Andreas Gudian
ccedca8890 #14 Adapt javadoc and order of method-usage within a type hierarchy 2015-05-28 18:23:53 +02:00
Andreas Gudian
619f8023d5 #14 Allow EnumMappings to be extended with @BeforeMapping/@AfterMapping methods 2015-05-28 18:20:45 +02:00
Andreas Gudian
68fc3af645 #14 Consider qualifiers when selecting @BeforeMapping/@AfterMapping methods 2015-05-28 18:20:31 +02:00
Andreas Gudian
ac8320b0a3 #14 Add support for @AfterMapping / @BeforeMapping methods, adapt MethodMatcher to allow multiple source arguments again 2015-05-28 18:15:04 +02:00
Andreas Gudian
2fd8e0a775 #365 Moving integration test to integration-test module (kept using only Java 8 for now) 2015-05-27 21:21:56 +02:00
Andreas Gudian
8e2e08d7e0 #365 Cleanups after review 2015-05-27 21:21:55 +02:00
Gunnar Morling
dab55e3790 #365 Adding integration test 2015-05-27 21:21:55 +02:00
Gunnar Morling
77298c750e #365 Making Services factory agnostic of specific services 2015-05-27 21:21:55 +02:00
Gunnar Morling
3ba4ded58c #365 Moving "spi" package into processor module; Simplifying AccessorNamingStrategy contract 2015-05-27 21:21:55 +02:00
Christian Schuster
e62b612851 #365 inject default implementation, add documentation for default behavior 2015-05-27 21:21:55 +02:00
Christian Schuster
130d58060f #365 use @code in javadoc comments 2015-05-27 21:21:55 +02:00
Christian Schuster
c2649571a1 #365 simplify caching 2015-05-27 21:21:54 +02:00
Christian Schuster
9f7fb11552 #365 include mapstruct-spi in mapstruct-processor 2015-05-27 21:21:54 +02:00
Christian Schuster
d0c685f6b8 #365 cache implementation 2015-05-27 21:21:54 +02:00
Christian Schuster
59c791034c #365 make accessor naming configurable 2015-05-27 21:21:54 +02:00
sjaakd
3be68b233e #512 more descriptive error message for forged collection and map mappings 2015-05-26 23:50:58 +02:00
Andreas Gudian
fbb80bfb25 #455 Add a fallback error reporting in case any uncaught exceptions occur - otherwise those errors are just swallowed and hard to find 2015-05-20 22:20:36 +02:00
sjaakd
28ebf763cd #551, fix for isAssignable problem in oracle_java_6 2015-05-20 19:58:08 +02:00
sjaakd
300d7824c4 #553, add Netbeans files to .gitignore and exlude from license check 2015-05-19 22:22:35 +02:00
sjaakd
379460b70d #513, template improvement, adding space before throws keyword 2015-05-18 15:32:06 +02:00
sjaakd
b98644cfeb #513, source code naming consistence exceptionTypes == thrownTypes 2015-05-18 15:31:24 +02:00
sjaakd
b4c514d479 #513, forged method should re-throw exceptions of used mapping methods 2015-05-18 15:14:01 +02:00
Andreas Gudian
fa1decd099 #544 downgrade checkstyle dependency to resolve guava version conflict with CDI weld 2015-05-17 23:16:15 +02:00
sjaakd
0890257700 #544 avoid that implementationtypes are added to imports in case of parameterized types 2015-05-17 23:16:15 +02:00
sjaakd
5ed7caedee #544 only implementation types should be added in case of creating a new collection as propertymapping 2015-05-17 23:16:15 +02:00
sjaakd
f69f035bd5 #544 targetType should not be added to imports in case of an update method selection 2015-05-17 23:16:15 +02:00
sjaakd
ac1f9aeaa5 #544 fix unused imports due to existing mapping target 2015-05-17 23:16:15 +02:00
Andreas Gudian
4a2f0c01ec #544 run some checkstyle rules on sources generated by our tests 2015-05-17 23:16:14 +02:00
Gunnar Morling
32828ff9eb #494 Fixing wrong indentation 2015-05-17 21:21:56 +02:00
Andreas Gudian
e31296d7f9 #494 Fix javadoc errors popping up during the build 2015-05-14 23:13:49 +02:00
Andreas Gudian
99f0111eeb #494 Add javadoc-generation to default build in order to catch errors early on. 2015-05-14 23:11:33 +02:00
sjaakd
124c2a4001 #515, introduction of string definition handling in IndentationCorrectingWriter 2015-05-12 23:16:45 +02:00
sjaakd
2ece25a086 #527 selection and forging of iterable - and map mapping methods with wildcards, extends for source, super for target 2015-05-08 22:21:23 +02:00
Gunnar Morling
a1baed46b0 #540 Adding Paul to copyright.txt 2015-05-08 21:37:37 +02:00
Paul Strugnell
f8586328f8 #540 use name() instead of toString() for enum to String conversion 2015-05-08 18:25:24 +08:00
Andreas Gudian
edac1b17cc #538 Add missing imports for a collection/map implementation and the parameter types 2015-05-04 15:13:18 +02:00
Andreas Gudian
8816b380c3 #534 fix array initializer for NullValueMappingStrategy.RETURN_DEFAULT 2015-04-10 11:22:46 +02:00
sjaakd
229537284a #320 fixing JodaTime unit test 2015-04-06 14:44:34 +02:00
sjaakd
bacf835c0d #516 Add NP check on adder property mapping including reproducer 2015-04-04 11:43:51 +02:00
Andreas Gudian
a431581da8 #523 fix type of assignment in GetterWrapperForCollectionsAndMaps 2015-03-30 20:50:38 +02:00
Andreas Gudian
f7433466cd #508 better caching of templates, disable caching in jar file connections to avoid suddenly closed InputStreams 2015-03-29 18:59:25 +02:00
Andreas Gudian
bcb722e2e9 #291 add test to verify that the simple case (target type with type arguments) already works, clean-up unnecessary "raw" definitions in templates 2015-03-28 10:48:27 +01:00
Andreas Gudian
fb6c4dbfbd #517 make order of target properties in generated code and in messages stable 2015-03-26 20:39:45 +01:00
Andreas Gudian
fb8a6e3ae0 #504 fix potential NPE in StreamEncoder (char-array can be null) 2015-03-17 13:52:12 +01:00
Gunnar Morling
0674a8780b #499 Extracting base class for shared mapping builder properties 2015-03-09 23:48:44 +01:00
Gunnar Morling
c030535ebe Adding Michael Pardo to copyright.txt 2015-03-08 13:08:01 +01:00
Michael Pardo
6435ab018e #481 Only add JaxbElement if the class exists 2015-03-08 09:37:59 +01:00
Gunnar Morling
f239841507 [maven-release-plugin] prepare for next development iteration 2015-03-05 00:07:48 +01:00
Gunnar Morling
e21c5fca26 [maven-release-plugin] prepare release 1.0.0.Beta4 2015-03-05 00:07:46 +01:00
Gunnar Morling
eddc951c01 Fixing several JavaDoc issues 2015-03-05 00:04:03 +01:00
Gunnar Morling
c52db7d1a2 Updating readme.md prior to 1.0.0.Beta4 release 2015-03-04 23:32:38 +01:00
sjaakd
c69a56c138 #160 Using update method, basic behavior. Single mapping methods on non collection / array properties. 2015-03-04 22:58:42 +01:00
sjaakd
776bc3d157 #160 Refactoring into targetReadAccessor and targetWriteAccessor and making them available to ftl templates 2015-03-04 21:58:33 +01:00
Gunnar Morling
bcf28c1cc1 #470 Adding import in case decorator is in another package than mapper interface 2015-03-04 14:22:19 +01:00
Gunnar Morling
b02d206de6 #304 Addressing review remarks 2015-03-04 00:34:08 +01:00
Gunnar Morling
21b89ea5e2 #304 Detecting unknown properties given via dependsOn() 2015-03-04 00:33:35 +01:00
Gunnar Morling
a332533dda #304 Raising an error in case a cycle is specified via dependsOn() 2015-03-04 00:33:35 +01:00
Gunnar Morling
6a43ee9391 #304 Formatting (unrelated) 2015-03-04 00:33:35 +01:00
Gunnar Morling
2d7ab089ff #304 Allowing to configure dependencies between properties via @Mapping#dependsOn() 2015-03-04 00:32:33 +01:00
sjaakd
9b888847ea #485 ArrayCopyWrapper local var possibly not safe 2015-03-03 23:30:37 +01:00
sjaakd
a381396839 #289 adding extra null check before add/putAll of a target collection when having a getter only targetaccessor 2015-03-02 09:54:14 +01:00
Andreas Gudian
bfaa524cb7 #460 add workaround for TypeElements that occasionally seem "empty" during incremental compilation in Eclipse JDT 2015-03-01 22:30:47 +01:00
sjaakd
b7e1388e0f #474 type in BeanMapping annotation 2015-03-01 20:16:46 +01:00
sjaakd
9fb2e6881c #474 refactoring, handling beanmapping similar as iterablemapping and mapmapping 2015-02-26 22:34:35 +01:00
sjaakd
1827d1125a #474 remove @NullValueMapping in favour of @Bean/@Map/@IterableMapping 2015-02-26 20:15:19 +01:00
Andreas Gudian
ea73669096 #168 Change retention of method-level annotations to CLASS, as they now need to be read from other classes as well 2015-02-25 14:50:39 +01:00
Andreas Gudian
9bfdc54b7b #163 correct typo in Javadoc code example 2015-02-25 09:49:33 +01:00
Gunnar Morling
bbeaa2117c #168 Formatting 2015-02-24 23:46:18 +01:00
Gunnar Morling
ec614a6e25 #168 Some JavaDoc clarifications 2015-02-24 23:30:42 +01:00
Gunnar Morling
1c258c2ef9 #168 Renaming MapperConfig to MapperConfiguration to avoid confusion with @MapperConfig 2015-02-24 22:33:28 +01:00
Andreas Gudian
952ee8526d #168 Allow to inherit mapping method configurations from the @MapperConfig-annotated type, either automatically when all method types match, or explicitly using @InheritConfiguration. 2015-02-24 14:24:24 +01:00
Gunnar Morling
2c845480a0 #465 Referencing formatter class by name rather than class object 2015-02-21 18:55:55 +01:00
Gunnar Morling
46145323ac #465 Fixing some whitespace issues in generated code 2015-02-21 18:55:46 +01:00
Gunnar Morling
a7d56e5122 #465 Adding import for Locale to Joda generated mappers if required 2015-02-21 18:55:29 +01:00
sjaakd
fe10248416 #459 error message parameter forgotten 2015-02-19 22:25:45 +01:00
Gunnar Morling
1659a6e8e5 #456 Avoiding to print multiple consecutive blank lines 2015-02-15 22:42:01 +01:00
sjaakd
37e5942c86 #160 allow selection of update methods by refactoring MethodMatcher but stopping selection of update method at new filter 2015-02-14 22:53:18 +01:00
Andreas Gudian
0c226f8388 #454 Do not check the existence of types in the classloader of the processor, but on the classpath of the sources 2015-02-11 20:11:34 +01:00
Andreas Gudian
892cdb2921 #323 make order of fields for used mappers stable (ordered as given in @Mapper#uses and then @MapperConfig#uses, omitting duplicates) 2015-02-08 17:34:36 +01:00
Andreas Gudian
762113aa60 #431 add JDK 9 to integration tests and remove processor_plugin_java_7 tests (they did exactly the same as the _java_8 variant, for what we are concerned).
Use -DprocessorIntegrationTest.canUseJdk9=false in case no JDK9 is configured in the toolchains.xml file
2015-02-08 11:10:53 +01:00
sjaakd
83ace655e1 #449 Handle XmlGregoriancalendar from String with empty date format as xml datatype 2015-02-06 22:52:33 +01:00
sjaakd
0ded169ecb #339 valid_date is not an error 2015-02-06 20:49:09 +01:00
sjaakd
55a50448be #141 removal of ListOfJaxbElemToListOfValue builtin method 2015-02-06 20:33:42 +01:00
sjaakd
4e10c8451c #194 Only generate field / imports for a referenced mapper if it is actually used 2015-02-06 20:18:14 +01:00
Gunnar Morling
0772dce41b #339 Some comment and typo fixes 2015-02-05 23:01:58 +01:00
sjaakd
b83c430758 #339 Uppercase for ENUM in messages, moving Diagnostic.Kind to Message 2015-02-04 21:46:10 +01:00
sjaakd
580d7869fd #339 fixing some spelling errors in messages 2015-02-03 00:14:30 +01:00
sjaakd
d61ca26652 #339 introduce centralized enum for messages 2015-02-03 00:11:45 +01:00
Gunnar Morling
31d2151b7b #412 Adding test for inner class of inner class 2015-02-01 17:33:41 +01:00
Ewald Volkert
2ebfd04fe9 #209, #412 Adding support for mapping static inner classes and enums by adding import declarations for static inner types also if declared in the same package 2015-02-01 17:33:38 +01:00
sjaakd
f778d6c5ad #434 construct resultType based on @BeanMaping#resultType when no factory method selected 2015-01-31 08:32:41 +01:00
sjaakd
897c8fbb6d #433 introduce resultType in @IterableMapping and @MapMapping 2015-01-31 08:00:01 +01:00
sjaakd
adcc89b184 #433 introduce resultType in @Mapping 2015-01-27 19:48:12 +01:00
sjaakd
490d454858 #437 Correct error message IterableMapping 2015-01-27 19:34:30 +01:00
sjaakd
de18f2b1d3 #410 Small template improvement, removing empty lines between fields 2015-01-27 19:32:16 +01:00
sjaakd
6ba04920ef #432 Selection of factory method based on Qualifier 2015-01-25 22:26:10 +01:00
Andreas Gudian
bd89a054e8 #424 Add Compiler implementation info to @Generated#comment 2015-01-25 21:02:45 +01:00
Andreas Gudian
8a449e12fd #427 Allow to specify more than one processor option for one test 2015-01-25 21:02:45 +01:00
Andreas Gudian
9737e0ba6e #426 allow to ignore checkstyle warnings explicitly by name using @SuppressWarnings 2015-01-25 21:02:45 +01:00
Gunnar Morling
483b88c6d2 #271 Improving JavaDocs for @Mapping#expression() 2015-01-25 11:26:48 +01:00
sjaakd
d3de4991c9 #429 Using Builder Pattern for SourceMethod 2015-01-24 10:29:55 +01:00
sjaakd
08ac33e3b1 #419 moving responsibility of target accessor determination to Type 2015-01-24 10:01:01 +01:00
Gunnar Morling
4c9653e277 #385 Improving docs, avoiding raw type warning 2015-01-22 23:32:41 +01:00
sjaakd
4e771244ad #385 Introduction of BeanMapping annotation and target type selection, reorder of selectors 2015-01-21 20:40:39 +01:00
sjaakd
65c272286f #385 Refactoring, factory methods should use selectors, preparing selector api for more criteria 2015-01-21 20:40:39 +01:00
sjaakd
7d2932c9b5 #390 included maven coordinates as comments in generated code 2015-01-21 20:27:52 +01:00
sjaakd
aa0e658f58 #410 do not instantiate a field (referenced mapper) when not used, e.g. only static referenced 2015-01-21 20:01:00 +01:00
sjaakd
d2796d7bf6 #410 use static custom mapper method instead of instance method call 2015-01-21 20:01:00 +01:00
sjaakd
151f24d306 #417 Making dateFormat in @IterableMapping optional, adding checks for @IterableMapping and @MapMapping 2015-01-20 21:39:06 +01:00
Andreas Gudian
9eec8ad6c9 #415 Rename packages that are named "target" to avoid them being ignored by the license plugin, add missing license header to some files 2015-01-07 21:57:59 +01:00
Gunnar Morling
13f9a5027a #213 Updating license header 2015-01-07 20:11:59 +01:00
Gunnar Morling
41429c6459 Adding one more contributor to copyright.txt 2015-01-06 23:44:41 +01:00
Gunnar Morling
74d97f89d7 Adding latest contributors to copyright.txt 2015-01-06 23:33:36 +01:00
Andreas Gudian
38181d4ff9 Fix error message for subsequent tests that fail with compile errors 2015-01-06 21:35:20 +01:00
Andreas Gudian
8e8bec933a #338 fix test that previously succeeded only because of a leak in the test classloader 2015-01-06 21:35:19 +01:00
Andreas Gudian
6201e6d61d #338 update to JUnit 4.12 and fix classloader leaks among the tests. 2015-01-06 21:35:19 +01:00
sjaakd
668f66eb73 #405 Fixing factory methods, not using raw type for @TargetType and superfluous implementation classes imports 2015-01-06 21:14:25 +01:00
Andreas Gudian
640d9dd571 #400 fix nested property mappings with Eclipse JDT compiler, extend the integration test accordingly. 2015-01-06 19:29:33 +01:00
sjaakd
2435f0206a Merge branch '398' of https://github.com/agudian/mapstruct into agudian_398 2015-01-04 19:57:29 +01:00
sjaakd
eb0de91bb1 #394 Fix for making ForgedMethod names unique when the param and returntype have similar simple names 2015-01-04 16:58:51 +01:00
Dilip Krishnan
555095e85c Demonstrates issue #394 2015-01-04 11:51:37 +01:00
Sebastian Hasait
883ccf92cd Fixed #407: primitive handling for nested properties works 2015-01-03 22:40:11 +01:00
Andreas Gudian
24984cb5be #398 allow autoboxing for primitive return types of property mapping methods to non-primitive properties 2014-12-30 19:18:28 +01:00
Timo E aus E
7e6084f3d5 #224 had to adapt parameter set for creating a new instance of Type after rebasing 2014-12-29 12:48:22 +01:00
Timo E aus E
374cf51fd4 Merge remote-tracking branch 'origin/dateFormatCheck' 2014-12-29 11:58:09 +01:00
sjaakd
c0438c1d15 #383 introduction of @InheritConfiguration to align update with create methods (several sources) 2014-12-28 22:22:31 +01:00
sjaakd
b2ef82ba5c #383 introduction of @InheritConfiguration to align update with create methods (single source) 2014-12-28 22:22:31 +01:00
Andreas Gudian
3e81651455 Minor formatting fixes of generated code 2014-12-28 21:13:09 +01:00
sjaakd
08cf60e46a #108 Aligning Array and Itterable mapping. Added ArrayCopyWrapper. 2014-12-28 20:52:01 +01:00
Gunnar Morling
44509a158e #108 Simplify error analysis in case null is passed via model include 2014-12-28 20:52:01 +01:00
Ewald Volkert
0b9ca3548d #274 Evaluate explicit types of method parameters and return types using Types#asMemberOf 2014-12-28 20:39:26 +01:00
teckhard
ebbeb7c549 #224 extended DefaultConversionContext for verifying the dateFormat if defined. Based on the source/target type it´s checked against SimpleDateFormat, Joda Time or Java 8 Time 2014-12-22 12:55:32 +01:00
Christian Schuster
677952c2fe #381 fix baseDir for JSR 330 integration test, add missing dependency 2014-12-13 17:57:59 +01:00
sjaakd
9b8076eff3 #374 non-compilable code for @NullValueMapping.RETURN_DEFAULT in combination with @MappingTarget 2014-12-13 17:53:16 +01:00
sjaakd
4730ded4d8 #373 Removing superfluous null check when mapping parameter directly. 2014-12-13 17:47:18 +01:00
sjaakd
c551a2d27d #373 Flattening and simplifying generated forged method 2014-12-13 17:47:18 +01:00
sjaakd
21010bae7f #373 Non-compilable code generated for nested property 2014-12-13 17:47:18 +01:00
sjaakd
1d9372a45b #375 safe variable for parameter in forged methods 2014-12-08 20:04:13 +01:00
sjaakd
e4de641911 #367 renaming method addEnclosingElementsIncludingSuper 2014-12-02 21:49:14 +01:00
Andreas Gudian
0c26b78702 #367 fix detection of overridden methods 2014-12-02 13:03:17 +01:00
Gunnar Morling
d0b3ba071d [maven-release-plugin] prepare for next development iteration 2014-11-30 19:43:18 +01:00
4290 changed files with 187518 additions and 31868 deletions

8
.codecov.yml Normal file
View File

@ -0,0 +1,8 @@
coverage:
status:
patch: off
project:
default:
# basic
threshold: 0.05
comment: off

2
.github/FUNDING.yml vendored Normal file
View File

@ -0,0 +1,2 @@
github: mapstruct
open_collective: mapstruct

45
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@ -0,0 +1,45 @@
name: Bug report
description: Create a report and help us improve
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
Please fill in all required fields with as many details as possible.
- type: textarea
id: expected
attributes:
label: Expected behavior
description: |
Describe what you were expecting MapStruct to do
placeholder: |
Here you can also add the generated code that you would like MapStruct to generate
- type: textarea
id: actual
attributes:
label: Actual behavior
description: |
Describe what you observed MapStruct did instead
placeholder: |
Here you can also add the generated code that MapStruct generated
- type: textarea
id: steps
attributes:
label: Steps to reproduce the problem
description: |
- Share your mapping configuration
- An [MCVE (Minimal Complete Verifiable Example)](https://stackoverflow.com/help/minimal-reproducible-example) can be helpful to provide a complete reproduction case
placeholder: |
Share your MapStruct configuration
validations:
required: true
- type: input
id: mapstruct-version
attributes:
label: MapStruct Version
description: |
Which MapStruct version did you use?
Note: While you can obviously continue using older versions of MapStruct, it may well be that your bug is already fixed. If you're using an older version, please also try to reproduce the bug in the latest version of MapStruct before reporting it.
placeholder: ex. MapStruct 1.5.2
validations:
required: true

16
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,16 @@
contact_links:
- name: MapStruct Discussions
url: https://github.com/mapstruct/mapstruct/discussions
about: Please use the MapStruct GitHub Discussions for open ended discussions and to reach out to the community.
- name: Stack Overflow
url: https://stackoverflow.com/questions/tagged/mapstruct
about: For questions about how to use MapStruct, consider asking your question on Stack Overflow, tagged [mapstruct].
- name: Documentation
url: https://mapstruct.org/documentation/stable/reference/html/
about: The MapStruct reference documentation.
- name: Gitter Chat
url: https://gitter.im/mapstruct/mapstruct-users
about: For realtime communication with the MapStruct community, consider writing in our Gitter chat room.
- name: MapStruct Examples
url: https://github.com/mapstruct/mapstruct-examples
about: Some examples of what can be achieved with MapStruct. (contributions are always welcome)

View File

@ -0,0 +1,43 @@
name: Feature Request
description: Suggest an idea
body:
- type: markdown
attributes:
value: |
Please describe the use-case you have. This will better help us understand the context in which you're looking for a new feature.
- type: textarea
id: use-case
attributes:
label: Use case
description: |
Please describe the use-case you have. This will better help us understand the context in which you're looking for a new feature.
placeholder: Describe the use-case here
validations:
required: true
- type: textarea
id: solution
attributes:
label: Generated Code
description: |
Please describe the possible generated code you'd like to see in MapStruct generate.
Please note, it's not always easy to describe a good solution. Describing the use-case above is much more important to us.
placeholder: Describe the possible solution here.
validations:
required: false
- type: textarea
id: workarounds
attributes:
label: Possible workarounds
description: |
Please describe the possible workarounds you've implemented to work around the lacking functionality.
placeholder: Describe the possible workarounds here.
validations:
required: false
- type: input
id: mapstruct-version
attributes:
label: MapStruct Version
description: What MapStruct version and edition did you try?
placeholder: ex. MapStruct 1.5.2
validations:
required: false

82
.github/scripts/update-website.sh vendored Normal file
View File

@ -0,0 +1,82 @@
#!/bin/bash
#
# Copyright MapStruct Authors.
#
# Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
#
# env vars:
# VERSION
# GH_BOT_EMAIL
# This script has been inspired by the JReleaser update-website.sh (https://github.com/jreleaser/jreleaser/blob/main/.github/scripts/update-website.sh)
set -e
function computePlainVersion() {
echo $1 | sed 's/\([[:digit:]]*\)\.\([[:digit:]]*\)\.\([[:digit:]]*\).*/\1.\2.\3/'
}
function computeMajorMinorVersion() {
echo $1 | sed 's/\([[:digit:]]*\)\.\([[:digit:]]*\).*/\1.\2/'
}
function isStable() {
local PLAIN_VERSION=$(computePlainVersion $1)
if [ "${PLAIN_VERSION}" == "$1" ]; then
echo "yes"
else
echo "no"
fi
}
STABLE=$(isStable $VERSION)
MAJOR_MINOR_VERSION=$(computeMajorMinorVersion $VERSION)
DEV_VERSION=`grep devVersion config.toml | sed 's/.*"\(.*\)"/\1/'`
MAJOR_MINOR_DEV_VERSION=$(computeMajorMinorVersion $DEV_VERSION)
STABLE_VERSION=`grep stableVersion config.toml | sed 's/.*"\(.*\)"/\1/'`
MAJOR_MINOR_STABLE_VERSION=$(computeMajorMinorVersion $STABLE_VERSION)
echo "📝 Updating versions"
SEDOPTION="-i"
if [[ "$OSTYPE" == "darwin"* ]]; then
SEDOPTION="-i ''"
fi
sed $SEDOPTION -e "s/^devVersion = \"\(.*\)\"/devVersion = \"${VERSION}\"/g" config.toml
if [ "${STABLE}" == "yes" ]; then
sed $SEDOPTION -e "s/^stableVersion = \"\(.*\)\"/stableVersion = \"${VERSION}\"/g" config.toml
if [ "${MAJOR_MINOR_STABLE_VERSION}" != ${MAJOR_MINOR_VERSION} ]; then
echo "📝 Updating new stable version"
# This means that we have a new stable version and we need to change the order of the releases.
sed $SEDOPTION -e "s/^order = \(.*\)/order = 500/g" data/releases/${MAJOR_MINOR_VERSION}.toml
NEXT_STABLE_ORDER=$((`ls -1 data/releases | wc -l` - 2))
sed $SEDOPTION -e "s/^order = \(.*\)/order = ${NEXT_STABLE_ORDER}/g" data/releases/${MAJOR_MINOR_STABLE_VERSION}.toml
git add data/releases/${MAJOR_MINOR_STABLE_VERSION}.toml
fi
elif [ "${MAJOR_MINOR_DEV_VERSION}" != "${MAJOR_MINOR_VERSION}" ]; then
echo "📝 Updating new dev version"
# This means that we are updating for a new dev version, but the last dev version is not the one that we are doing.
# Therefore, we need to update add the new data configuration
cp data/releases/${MAJOR_MINOR_DEV_VERSION}.toml data/releases/${MAJOR_MINOR_VERSION}.toml
sed $SEDOPTION -e "s/^order = \(.*\)/order = 1000/g" data/releases/${MAJOR_MINOR_VERSION}.toml
fi
sed $SEDOPTION -e "s/^name = \"\(.*\)\"/name = \"${VERSION}\"/g" data/releases/${MAJOR_MINOR_VERSION}.toml
sed $SEDOPTION -e "s/^releaseDate = \(.*\)/releaseDate = $(date +%F)/g" data/releases/${MAJOR_MINOR_VERSION}.toml
git add data/releases/${MAJOR_MINOR_VERSION}.toml
git add config.toml
echo "📝 Updating distribution resources"
tar -xf tmp/mapstruct-${VERSION}-dist.tar.gz --directory tmp
rm -rf static/documentation/${MAJOR_MINOR_VERSION}
cp -R tmp/mapstruct-${VERSION}/docs static/documentation/${MAJOR_MINOR_VERSION}
mv static/documentation/${MAJOR_MINOR_VERSION}/reference/html/mapstruct-reference-guide.html static/documentation/${MAJOR_MINOR_VERSION}/reference/html/index.html
git add static/documentation/${MAJOR_MINOR_VERSION}
git config --global user.email "${GH_BOT_EMAIL}"
git config --global user.name "GitHub Action"
git commit -a -m "Releasing version ${VERSION}"
git push

21
.github/workflows/java-ea.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Java EA
on: [push]
env:
MAVEN_ARGS: -V -B --no-transfer-progress -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
jobs:
test_jdk_ea:
name: 'Linux JDK EA'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Set up JDK'
uses: oracle-actions/setup-java@v1
with:
website: jdk.java.net
release: EA
- name: 'Test'
run: ./mvnw ${MAVEN_ARGS} -Djacoco.skip=true install -DskipDistribution=true

20
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: Mac OS CI
on: push
env:
MAVEN_ARGS: -V -B --no-transfer-progress -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
jobs:
mac:
name: 'Mac OS'
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: 'Set up JDK 21'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: 'Test'
run: ./mvnw ${MAVEN_ARGS} install

60
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,60 @@
name: CI
on: [push, pull_request]
env:
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_ARGS: -V -B --no-transfer-progress -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
jobs:
test_jdk:
strategy:
fail-fast: false
matrix:
java: [21]
name: 'Linux JDK ${{ matrix.java }}'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Set up JDK'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: 'Test'
run: ./mvnw ${MAVEN_ARGS} -Djacoco.skip=${{ matrix.java != 21 }} install -DskipDistribution=${{ matrix.java != 21 }}
- name: 'Generate coverage report'
if: matrix.java == 21
run: ./mvnw jacoco:report
- name: 'Upload coverage to Codecov'
if: matrix.java == 21
uses: codecov/codecov-action@v2
- name: 'Publish Snapshots'
if: matrix.java == 21 && github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'mapstruct/mapstruct'
run: ./mvnw -s etc/ci-settings.xml -DskipTests=true -DskipDistribution=true deploy
integration_test_jdk:
strategy:
fail-fast: false
matrix:
java: [ 8, 11, 17 ]
name: 'Linux JDK ${{ matrix.java }}'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v4
- name: 'Set up JDK 21 for building everything'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: 'Install Processor'
run: ./mvnw ${MAVEN_ARGS} -DskipTests install -pl processor -am
- name: 'Set up JDK ${{ matrix.java }} for running integration tests'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
- name: 'Run integration tests'
run: ./mvnw ${MAVEN_ARGS} verify -pl integrationtest

117
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,117 @@
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: true
next:
description: 'Next version'
required: false
jobs:
release:
# This job has been inspired by the moditect release (https://github.com/moditect/moditect/blob/main/.github/workflows/release.yml)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'zulu'
cache: maven
- name: Set release version
id: version
run: |
RELEASE_VERSION=${{ github.event.inputs.version }}
NEXT_VERSION=${{ github.event.inputs.next }}
PLAIN_VERSION=`echo ${RELEASE_VERSION} | awk 'match($0, /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)/) { print substr($0, RSTART, RLENGTH); }'`
COMPUTED_NEXT_VERSION="${PLAIN_VERSION}-SNAPSHOT"
if [ -z $NEXT_VERSION ]
then
NEXT_VERSION=$COMPUTED_NEXT_VERSION
fi
./mvnw -ntp -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION -pl :mapstruct-parent -DgenerateBackupPoms=false
git config --global user.email "${{ vars.GH_BOT_EMAIL }}"
git config --global user.name "GitHub Action"
git commit -a -m "Releasing version $RELEASE_VERSION"
git push
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV
echo "PLAIN_VERSION=$PLAIN_VERSION" >> $GITHUB_ENV
- name: Stage
run: |
export GPG_TTY=$(tty)
./mvnw -ntp -B --file pom.xml \
-Dmaven.site.skip=true -Drelease=true -Ppublication,stage
- name: Release
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./mvnw -ntp -B --file pom.xml -pl :mapstruct-parent -Pjreleaser jreleaser:release
- name: JReleaser output
if: always()
uses: actions/upload-artifact@v4
with:
name: jreleaser-release
path: |
parent/target/jreleaser/trace.log
parent/target/jreleaser/output.properties
- name: Reset NEXT_RELEASE_CHANGELOG.md
run: |
echo -e "### Features\n\n### Enhancements\n\n### Bugs\n\n### Documentation\n\n### Build\n" > NEXT_RELEASE_CHANGELOG.md
- name: Set next version
run: |
./mvnw -ntp -B versions:set versions:commit -DnewVersion=${{ env.NEXT_VERSION }} -pl :mapstruct-parent -DgenerateBackupPoms=false
sed -i -e "s@project.build.outputTimestamp>.*</project.build.outputTimestamp@project.build.outputTimestamp>\${git.commit.author.time}</project.build.outputTimestamp@g" parent/pom.xml
git config --global user.email "${{ vars.GH_BOT_EMAIL }}"
git config --global user.name "GitHub Action"
git commit -a -m "Next version ${{ env.NEXT_VERSION }}"
git push
update-website:
# This job has been inspired by the JReleaser update-website job (https://github.com/jreleaser/jreleaser/blob/main/.github/workflows/release.yml)
name: Update Website
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: mapstruct/mapstruct.org
ref: main
fetch-depth: 0
token: ${{ secrets.GIT_WEBSITE_ACCESS_TOKEN }}
- name: Download assets
shell: bash
run: |
curl -sL https://raw.githubusercontent.com/mapstruct/mapstruct/main/.github/scripts/update-website.sh --output update-website.sh --create-dirs --output-dir tmp
curl -sL "https://github.com/mapstruct/mapstruct/releases/download/${VERSION}/mapstruct-${VERSION}-dist.tar.gz" --output mapstruct-${VERSION}-dist.tar.gz --create-dirs --output-dir tmp
env:
VERSION: ${{ github.event.inputs.version }}
- name: Commit
shell: bash
env:
VERSION: ${{ github.event.inputs.version }}
GH_BOT_EMAIL: ${{ vars.GH_BOT_EMAIL }}
run: |
chmod +x tmp/update-website.sh
tmp/update-website.sh

20
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,20 @@
name: Windows CI
on: push
env:
MAVEN_ARGS: -V -B --no-transfer-progress -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
jobs:
windows:
name: 'Windows'
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: 'Set up JDK 21'
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
- name: 'Test'
run: ./mvnw %MAVEN_ARGS% install

11
.gitignore vendored
View File

@ -1,5 +1,6 @@
# Eclipse
.metadata
.recommenders
.classpath
.project
.settings
@ -13,6 +14,14 @@
*.iws
.idea
# Netbeans
nb-configuration.xml
# Build
/*/target
/**/target/
test-output
# Misc.
.DS_Store
checkstyle.cache
.flattened-pom.xml

19
.mvn/wrapper/maven-wrapper.properties vendored Normal file
View File

@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
wrapperVersion=3.3.2
distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip

View File

@ -5,13 +5,15 @@ You love MapStruct but miss a certain feature? You found a bug and want to repor
* Source code: [http://github.com/mapstruct/mapstruct](http://github.com/mapstruct/mapstruct)
* Issue tracker: [https://github.com/mapstruct/mapstruct/issues](https://github.com/mapstruct/mapstruct/issues)
* Discussions: Join the [mapstruct-users](https://groups.google.com/forum/?fromgroups#!forum/mapstruct-users) Google group
* CI build: [https://mapstruct.ci.cloudbees.com](https://mapstruct.ci.cloudbees.com)
* CI build: [https://github.com/mapstruct/mapstruct/actions/](https://github.com/mapstruct/mapstruct/actions)
MapStruct follows the _Fork & Pull_ development approach. To get started just fork the [MapStruct repository](http://github.com/mapstruct/mapstruct) to your GitHub account and create a new topic branch for each change. Once you are done with your change, submit a [pull request](https://help.github.com/articles/using-pull-requests) against the MapStruct repo.
When doing changes, keep the following best practices in mind:
* Provide test cases
* Use the code formatter for your IDE
* [IntelliJ Formatter](https://github.com/mapstruct/mapstruct/blob/master/etc/mapstruct.xml)
* Update the [reference documentation](mapstruct.org/documentation) on [mapstruct.org](mapstruct.org) where required
* Discuss new features you'd like to implement at the [Google group](https://groups.google.com/forum/?fromgroups#!forum/mapstruct-users) before getting started
* Create one pull request per feature

View File

@ -1,19 +1,6 @@
Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
and/or other contributors as indicated by the @authors tag. See the
copyright.txt file in the distribution for a full listing of all
contributors.
Copyright MapStruct Authors.
MapStruct is licensed under the Apache License, Version 2.0 (the
"License"); you may not use this software except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
MapStruct is licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
------------------------------------------------------------------------

29
NEXT_RELEASE_CHANGELOG.md Normal file
View File

@ -0,0 +1,29 @@
### Features
* Support for Java 21 Sequenced Collections (#3240)
### Enhancements
* Add support for locale parameter for numberFormat and dateFormat (#3628)
* Detect Builder without a factory method (#3729) - With this if there is an inner class that ends with `Builder` and has a constructor with parameters,
it will be treated as a potential builder.
Builders through static methods on the type have a precedence.
* Behaviour change: Warning when the target has no target properties (#1140)
### Bugs
* Improve error message when mapping non-iterable to array (#3786)
### Documentation
### Build
### Behaviour Change
#### Warning when the target has no target properties
With this change, if the target bean does not have any target properties, a warning will be shown.
This is like this to avoid potential mistakes by users, where they might think that the target bean has properties, but it does not.

View File

@ -1,22 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
and/or other contributors as indicated by the @authors tag. See the
copyright.txt file in the distribution for a full listing of all
contributors.
Copyright MapStruct Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@ -25,7 +12,7 @@
<parent>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0.0.Beta3</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@ -33,15 +20,7 @@
<packaging>jar</packaging>
<name>MapStruct Build Configuration</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
</project>

View File

@ -15,6 +15,8 @@
<property name="basedir" value="${basedir}"/>
-->
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!-- Checks that each Java package has a Javadoc file used for commenting. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
<!--
@ -27,7 +29,16 @@
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
<module name="FileLength"/>
<module name="FileLength">
<property name="max" value="2500"/>
</module>
<module name="LineLength">
<property name="max" value="120"/>
<property name="fileExtensions" value="java" />
</module>
<module name="SuppressWithPlainTextCommentFilter"/>
<!-- Following interprets the header file as regular expressions. -->
<!-- <module name="RegexpHeader"/> -->
@ -52,12 +63,15 @@
<property name="message" value="Line has trailing spaces"/>
</module>
<module name="RegexpSingleline">
<!-- do not allow a package declaration that contains ".target." or "target;" -->
<property name="format" value="^package .*\.target[\.;]"/>
<property name="message" value="Do not use &quot;target&quot; as package name element"/>
</module>
<module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/>
<!-- Required for SuppressionCommentFilter -->
<module name="FileContentsHolder"/>
<module name="SuppressWarningsHolder"/>
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
@ -110,10 +124,6 @@
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="120"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber">
<property name="max" value="10"/>
</module>
@ -136,8 +146,15 @@
</module>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<module name="WhitespaceAround">
<property name="ignoreEnhancedForColon" value="false"/>
</module>
<module name="EmptyLineSeparator">
<property name="tokens" value="IMPORT, CLASS_DEF, INTERFACE_DEF, STATIC_INIT, INSTANCE_INIT, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
<property name="allowNoEmptyLineBetweenFields" value="true"/>
<property name="allowMultipleEmptyLines" value="false"/>
</module>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
@ -177,7 +194,10 @@
<!-- <module name="FinalClass"/> -->
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="VisibilityModifier">
<property name="packageAllowed" value="true" />
<property name="protectedAllowed" value="true" />
</module>
<!-- Miscellaneous other checks. -->
@ -187,8 +207,9 @@
<!-- <module name="TodoComment"/> -->
<module name="UpperEll"/>
<module name="SuppressionCommentFilter"/>
</module>
<module name="SuppressionCommentFilter"/>
<module name="SuppressWarningsFilter"/>
</module>

View File

@ -10,8 +10,8 @@
<!-- the annotation processor may not use the annotations or enums specified in org.mapstruct directly... -->
<disallow pkg="org.mapstruct" exact-match="true" />
<subpackage name="prism">
<!-- ... with exception to the package org.mapstruct.ap.prism -->
<subpackage name="internal.gem">
<!-- ... with exception to the package org.mapstruct.ap.internal.gem -->
<allow pkg=".*" regex="true" />
</subpackage>
<subpackage name="test">

View File

@ -1,8 +1,73 @@
Contributors
Contributors
============
Andreas Gudian
Christian Schuster
Gunnar Morling
Sjaak Derksen
Timo Eckhardt
Alexandr Shalugin - https://github.com/shalugin
Amine Touzani - https://github.com/ttzn
Andreas Gudian - https://github.com/agudian
Andrei Arlou - https://github.com/Captain1653
Andres Jose Sebastian Rincon Gonzalez - https://github.com/stianrincon
Arne Seime - https://github.com/seime
Christian Bandowski - https://github.com/chris922
Chris DeLashmutt - https://github.com/cdelashmutt-pivotal
Christian Kosmowski - https://github.com/ckosmowski
Christian Schuster - https://github.com/chschu
Christophe Labouisse - https://github.com/ggtools
Ciaran Liedeman - https://github.com/cliedeman
Cindy Wang - https://github.com/birdfriend
Cornelius Dirmeier - https://github.com/cornzy
David Feinblum - https://github.com/dvfeinblum
Darren Rambaud - https://github.com/xyzst
Dekel Pilli - https://github.com/dekelpilli
Dilip Krishnan - https://github.com/dilipkrish
Dmytro Polovinkin - https://github.com/navpil
Ewald Volkert - https://github.com/eforest
Eric Martineau - https://github.com/ericmartineau
Ewald Volkert - https://github.com/eforest
Filip Hrisafov - https://github.com/filiphr
Florian Tavares - https://github.com/neoXfire
Gervais Blaise - https://github.com/gervaisb
Gibou Damien - https://github.com/dmngb
Gunnar Morling - https://github.com/gunnarmorling
Ivo Smid - https://github.com/bedla
Jason Bodnar - https://github.com/Blackbaud-JasonBodnar
Jeroen van Wilgenburg - https://github.com/jvwilge
Jeff Smyth - https://github.com/smythie86
João Paulo Bassinello - https://github.com/jpbassinello
Jonathan Kraska - https://github.com/jakraska
Joshua Spoerri - https://github.com/spoerri
Jude Niroshan - https://github.com/JudeNiroshan
Justyna Kubica-Ledzion - https://github.com/JKLedzion
Kemal Özcan - https://github.com/yekeoe
Kevin Grüneberg - https://github.com/kevcodez
Lukas Lazar - https://github.com/LukeLaz
Nikolas Charalambidis - https://github.com/Nikolas-Charalambidis
Michael Pardo - https://github.com/pardom
Muhammad Usama - https://github.com/the-mgi
Mustafa Caylak - https://github.com/luxmeter
Oliver Ehrenmüller - https://github.com/greuelpirat
Oliver Erhart - https://github.com/thunderhook
Paul Strugnell - https://github.com/ps-powa
Pascal Grün - https://github.com/pascalgn
Pavel Makhov - https://github.com/streetturtle
Peter Larson - https://github.com/pjlarson
Remko Plantenga - https://github.com/sonata82
Remo Meier - https://github.com/remmeier
Richard Lea - https://github.com/chigix
Saheb Preet Singh - https://github.com/sahebpreet
Samuel Wright - https://github.com/samwright
Sebastian Haberey - https://github.com/sebastianhaberey
Sebastian Hasait - https://github.com/shasait
Sean Huang - https://github.com/seanjob
Sjaak Derksen - https://github.com/sjaakd
Stefan May - https://github.com/osthus-sm
Taras Mychaskiw - https://github.com/twentylemon
Thibault Duperron - https://github.com/Zomzog
Tomáš Poledný - https://github.com/Saljack
Tobias Meggendorfer - https://github.com/incaseoftrouble
Tillmann Gaida - https://github.com/Tillerino
Timo Eckhardt - https://github.com/timoe
Tomek Gubala - https://github.com/vgtworld
Valentin Kulesh - https://github.com/unshare
Vincent Alexander Beelte - https://github.com/grandmasterpixel
Winter Andreas - https://github.dev/wandi34
Xiu Hong Kooi - https://github.com/kooixh

View File

@ -1,77 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
and/or other contributors as indicated by the @authors tag. See the
copyright.txt file in the distribution for a full listing of all
contributors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0.0.Beta3</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>mapstruct-common</artifactId>
<packaging>jar</packaging>
<name>MapStruct Core Common</name>
<properties>
<maven.javadoc.skip>true</maven.javadoc.skip>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,62 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
/**
* Strategy for propagating the value of collection-typed properties from source to target.
*
* @author Sjaak Derksen
*/
public enum CollectionMappingStrategy {
/**
* The setter of the target property will be used to propagate the value:
* {@code orderDto.setOrderLines( order.getOrderLines )}.
* <p>
* If no setter is available but a getter method, this will be used, under the assumption it has been initialized:
* {@code orderDto.getOrderLines().addAll( order.getOrderLines )}.
*/
ACCESSOR_ONLY,
/**
* If present, the setter of the target property will be used to propagate the value:
* {@code orderDto.setOrderLines( order.getOrderLines )}.
* <p>
* If no setter but and adder method is present, that adder will be invoked for each element of the source
* collection: {@code order.addOrderLine( orderLine() )}.
* <p>
* If neither a setter nor an adder method but a getter for the target property is present, that getter will be
* used, assuming it returns an initialized collection: If no setter is available, MapStruct will first look for an
* adder method before resorting to a getter.
*/
SETTER_PREFERRED,
/**
* Identical to {@link #SETTER_PREFERRED}, only that adder methods will be preferred over setter methods, if both
* are present for a given collection-typed property.
*/
ADDER_PREFERRED,
/**
* If given via {@link Mapper#collectionMappingStrategy()}, causes the setting specified via
* {@link MapperConfig#collectionMappingStrategy()} to be applied, if present. Otherwise causes
* {@link #ACCESSOR_ONLY} to be applied.
*/
DEFAULT;
}

View File

@ -1,56 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Specifies a decorator to be applied to a generated mapper, which e.g. can be used to amend mappings performed by
* generated mapping methods.
* <p>
* A typical decorator implementation will be an abstract class and only implement/override a subset of the methods of
* the mapper type which it decorates. All methods not implemented or overridden by the decorator will be implemented by
* the code generator.
* <p>
* If a constructor with a single parameter accepting the type of the decorated mapper is present, a delegate with
* generated implementations of all the mapper methods will be passed to this constructor. A typical implementation will
* store the passed delegate in a field of the decorator and make use of it in the decorator methods.
* <p>
* <b>NOTE:</b> The decorator feature is considered experimental and it may change in future releases. Currently
* decorators are only supported for the default component model, not for the CDI and Spring models.
*
* @author Gunnar Morling
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface DecoratedWith {
/**
* The decorator type. Must extend or implement the mapper type to which it is applied.
* <p>
* The decorator type must either have a default constructor or a constructor with a single parameter accepting the
* type of the decorated mapper.
*
* @return the decorator type
*/
Class<?> value();
}

View File

@ -1,51 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Advises the code generator to apply all the {@link Mapping}s from an inverse mapping method to the annotated method
* as well. An inverse mapping method is a method which has the annotated method's source type as target type (return
* type or indicated through a parameter annotated with {@link MappingTarget}) and the annotated method's target type as
* source type.
* <p>
* Any mappings given on the annotated method itself are added to those mappings inherited from the inverse method. In
* case of a conflict local mappings take precedence over inherited mappings.
* <p>
* If more than one matching inverse method exists, the name of the method to inherit the configuration from must be
* specified via {@link #name()}
*
* @author Sjaak Derksen
*/
@Target( ElementType.METHOD )
@Retention( RetentionPolicy.SOURCE )
public @interface InheritInverseConfiguration {
/**
* The name of the inverse mapping method to inherit the mappings from. Needs only to be specified in case more than
* one inverse method with matching source and target type exists.
*
* @return The name of the inverse mapping method to inherit the mappings from.
*/
String name() default "";
}

View File

@ -1,55 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Configures the mapping between two iterable types, e.g. {@code List<String>} and {@code List<Date>}.
*
* @author Gunnar Morling
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface IterableMapping {
/**
* A format string as processable by {@link SimpleDateFormat} if the annotated method maps from an iterable of
* {@code String} to an iterable {@link Date} or vice-versa. Will be ignored for all other element types.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
*/
String dateFormat();
/**
* A qualifier can be specified to aid the selection process of a suitable mapper. This is useful in case multiple
* mappers (hand written of internal) qualify and result in an 'Ambiguous mapping methods found' error.
*
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
*/
Class<? extends Annotation>[] qualifiedBy() default { };
}

View File

@ -1,76 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Configures the mapping between two map types, e.g. {@code Map<String, String>} and {@code Map<Long, Date>}.
*
* @author Gunnar Morling
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface MapMapping {
/**
* A format string as processable by {@link SimpleDateFormat} if the annotated method maps from a map with key type
* {@code String} to an map with key type {@link Date} or vice-versa. Will be ignored for all other key types.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
*/
String keyDateFormat() default "";
/**
* A format string as processable by {@link SimpleDateFormat} if the annotated method maps from a map with value
* type {@code String} to an map with value type {@link Date} or vice-versa. Will be ignored for all other value
* types.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
*/
String valueDateFormat() default "";
/**
* A key value qualifier can be specified to aid the selection process of a suitable mapper. This is useful in
* case multiple mappers (hand written of internal) qualify and result in an 'Ambiguous mapping methods found'
* error.
*
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
*/
Class<? extends Annotation>[] keyQualifiedBy() default { };
/**
* A value qualifier can be specified to aid the selection process of a suitable mapper. This is useful in case
* multiple mappers (hand written of internal) qualify and result in an 'Ambiguous mapping methods found' error.
*
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
*/
Class<? extends Annotation>[] valueQualifiedBy() default { };
}

View File

@ -1,115 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.factory.Mappers;
/**
* Marks an interface as mapper interface and activates the generation of a
* mapper implementation for that interface.
*
* @author Gunnar Morling
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface Mapper {
/**
* The mapper types used by this mapper.
*
* @return The mapper types used by this mapper.
*/
Class<?>[] uses() default { };
/**
* Additional types for which an import statement is to be added to the generated mapper implementation class.
* This allows to refer to those types from within mapping expressions given via {@link Mapping#expression()} using
* their simple name rather than their fully-qualified name.
*
* @return classes to add in the imports of the generated implementation.
*/
Class<?>[] imports() default { };
/**
* How unmapped properties of the target type of a mapping should be
* reported. The method overrides an unmappedTargetPolicy set in a central
* configuration set by {@link #config() }
*
* @return The reporting policy for unmapped target properties.
*/
ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.DEFAULT;
/**
* Specifies the component model to which the generated mapper should
* adhere. Supported values are
* <ul>
* <li> {@code default}: the mapper uses no component model, instances are
* typically retrieved via {@link Mappers#getMapper(Class)}</li>
* <li>
* {@code cdi}: the generated mapper is an application-scoped CDI bean and
* can be retrieved via {@code @Inject}</li>
* <li>
* {@code spring}: the generated mapper is a Spring bean and
* can be retrieved via {@code @Autowired}</li>
* <li>
* {@code jsr330}: the generated mapper is annotated with {@code @Named} and
* can be retrieved via {@code @Inject}</li>
* </ul>
* The method overrides an unmappedTargetPolicy set in a central configuration set
* by {@link #config() }
*
* @return The component model for the generated mapper.
*/
String componentModel() default "default";
/**
* A class annotated with {@link MapperConfig} which should be used as configuration template. Any settings given
* via {@link Mapper} will take precedence over the settings from the referenced configuration source. The list of
* referenced mappers will contain all mappers given via {@link Mapper#uses()} and {@link MapperConfig#uses()}.
*
* @return A class which should be used as configuration template.
*/
Class<?> config() default void.class;
/**
* The strategy to be applied when propagating the value of collection-typed properties. By default, only JavaBeans
* accessor methods (setters or getters) will be used, but it is also possible to invoke a corresponding adder
* method for each element of the source collection (e.g. {@code orderDto.addOrderLine()}).
* <p>
* Any setting given for this attribute will take precedence over {@link MapperConfig#collectionMappingStrategy()},
* if present.
*
* @return The strategy applied when propagating the value of collection-typed properties.
*/
CollectionMappingStrategy collectionMappingStrategy() default CollectionMappingStrategy.DEFAULT;
/**
* The strategy to be applied when {@code null} is passed as source value to the methods of this mapper. If no
* strategy is configured, the strategy given via {@link MapperConfig#nullValueMappingStrategy()} will be applied,
* using {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapper.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT;
}

View File

@ -1,92 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.factory.Mappers;
/**
* Marks a class-, interface-, enum declaration as (common) configuration.
*
* The {@link #unmappedTargetPolicy() } and {@link #componentModel() } can be overruled by a specific {@link Mapper}
* annotation. {@link #uses() } will be used in addition to what is specified in the {@link Mapper} annotation.
*
* @author Sjaak Derksen
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface MapperConfig {
/**
* The mapper types used by this mapper.
*
* @return The mapper types used by this mapper.
*/
Class<?>[] uses() default { };
/**
* How unmapped properties of the target type of a mapping should be
* reported.
*
* @return The reporting policy for unmapped target properties.
*/
ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.WARN;
/**
* Specifies the component model to which the generated mapper should
* adhere. Supported values are
* <ul>
* <li> {@code default}: the mapper uses no component model, instances are
* typically retrieved via {@link Mappers#getMapper(Class)}</li>
* <li>
* {@code cdi}: the generated mapper is an application-scoped CDI bean and
* can be retrieved via {@code @Inject}</li>
* <li>
* {@code spring}: the generated mapper is a Spring bean and
* can be retrieved via {@code @Autowired}</li>
* <li>
* {@code jsr330}: the generated mapper is annotated with {@code @Named} and
* can be retrieved via {@code @Inject}</li>
* </ul>
*
* @return The component model for the generated mapper.
*/
String componentModel() default "default";
/**
* The strategy to be applied when propagating the value of collection-typed properties. By default, only JavaBeans
* accessor methods (setters or getters) will be used, but it is also possible to invoke a corresponding adder
* method for each element of the source collection (e.g. {@code orderDto.addOrderLine()}).
*
* @return The strategy applied when propagating the value of collection-typed properties.
*/
CollectionMappingStrategy collectionMappingStrategy() default CollectionMappingStrategy.DEFAULT;
/**
* The strategy to be applied when {@code null} is passed as source value to mapping methods. If no strategy is
* configured, {@link NullValueMappingStrategy#RETURN_NULL} will be used by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to mapping methods.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.DEFAULT;
}

View File

@ -1,36 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares a parameter of a mapping method to be the target of the mapping.
* <p>
* Not more than one parameter can be declared as {@code MappingTarget}.
*
* @author Andreas Gudian
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface MappingTarget {
}

View File

@ -1,44 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Specifies how the annotated method should deal with {@code null} values.
* <p>
* If no strategy is configured explicitly for a given method, the configuration from the enclosing mapper will be
* applied, using {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @author Sjaak Derksen
*/
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.SOURCE)
public @interface NullValueMapping {
/**
* The strategy for mapping null values.
*
* @return The strategy for mapping null values
*/
NullValueMappingStrategy value();
}

View File

@ -1,58 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
/**
* Strategy for dealing with {@code null} values passed to mapping methods.
*
* @author Sjaak Derksen
*/
public enum NullValueMappingStrategy {
/**
* If {@code null} is passed to a mapping method, {@code null} will be returned. That's the default behavior if no
* alternative strategy is configured globally, for given mapper or method.
*/
RETURN_NULL,
/**
* If {@code null} is passed to a mapping method, a default value will be returned. The value depends on the kind of
* the annotated method:
* <ul>
* <li>For bean mapping methods the target type will be instantiated and returned. Any properties of the target type
* which are mapped via {@link Mapping#expression()} or {@link Mapping#constant()} will be populated based on the
* given expression or constant. Note that expressions must be prepared to deal with {@code null} values in this
* case.</li>
* <li>For iterable mapping methods an empty collection will be returned.</li>
* <li>For map mapping methods an empty map will be returned.</li>
* </ul>
*/
RETURN_DEFAULT,
/**
* When given via {@link Mapper#nullValueMappingStrategy()}, causes the setting specified via
* {@link MapperConfig#nullValueMappingStrategy()} to be applied, if present.
* <p>
* When given via {@link NullValueMapping#value()}, causes the setting specified via
* {@link Mapper#nullValueMappingStrategy() ()} to be applied, if present.
* <p>
* Otherwise causes {@link #RETURN_NULL} to be applied.
*/
DEFAULT;
}

View File

@ -1,50 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares an annotation type to be a qualifier. Qualifier annotations allow unambiguously identify a suitable mapping
* method in case several methods qualify to map a bean property, iterable element etc.
* <p>
* For more info see:
* <ul>
* <li>{@link Mapping#qualifiedBy() }</li>
* <li>{@link IterableMapping#qualifiedBy() }</li>
* <li>{@link MapMapping#keyQualifiedBy() }</li>
* <li>{@link MapMapping#valueQualifiedBy() }</li>
* </ul>
* Example:
* <pre>
* &#64;Qualifier
* &#64;Target(ElementType.METHOD)
* &#64;Retention(RetentionPolicy.SOURCE)
* public &#64;interface EnglishToGerman {}
* </pre>
*
* @author Sjaak Derksen
*/
@Target( ElementType.ANNOTATION_TYPE )
@Retention( RetentionPolicy.CLASS )
public @interface Qualifier {
}

View File

@ -1,56 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import javax.tools.Diagnostic.Kind;
/**
* Policy for reporting issues occurring during the generation of a mapper
* implementation.
*
* @author Gunnar Morling
*/
public enum ReportingPolicy {
/**
* No report will be created for the given issue.
*/
IGNORE,
/**
* A report with {@link Kind#WARNING} will be created for the given issue.
*/
WARN,
/**
* A report with {@link Kind#ERROR} will be created for the given issue,
* causing the compilation to fail.
*/
ERROR,
/**
* When given as value for {@link Mapper#unmappedTargetPolicy()}, the setting from the configuration source
* referenced via {@link Mapper#config()} will be applied.
* <p>
* Otherwise (no configuration source is referenced, or this value is given via
* {@link MapperConfig#unmappedTargetPolicy()}), a report with {@link Kind#WARNING} will be created for the given
* issue.
*/
DEFAULT;
}

View File

@ -1,37 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares a parameter of a custom mapping method to be populated with the target type of the mapping.
* <p>
* Not more than one parameter can be declared as {@code TargetType} and that parameter needs to be of type
* {@link Class} (may be parameterized), or a super-type of it.
*
* @author Andreas Gudian
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface TargetType {
}

View File

@ -1,84 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.factory;
import org.mapstruct.Mapper;
/**
* Factory for obtaining mapper instances if no explicit component model such as CDI is configured via
* {@link Mapper#componentModel()}.
* <p>
* Mapper implementation types are expected to have the same fully qualified name as their interface type, with the
* suffix {@code Impl} appended. When using this factory, mapper types - and any mappers they use - are instantiated by
* invoking their public no-args constructor.
* <p>
* By convention, a single instance of each mapper is retrieved from the factory and exposed on the mapper interface
* type by declaring a member named {@code INSTANCE} like this:
*
* <pre>
* &#064;Mapper
* public interface CustomerMapper {
*
* CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class );
*
* // mapping methods...
* }
* </pre>
*
* @author Gunnar Morling
*/
public class Mappers {
private static final String IMPLEMENTATION_SUFFIX = "Impl";
private Mappers() {
}
/**
* Returns an instance of the given mapper type.
*
* @param clazz The type of the mapper to return.
* @param <T> The type of the mapper to create.
* @return An instance of the given mapper type.
*/
public static <T> T getMapper(Class<T> clazz) {
try {
// Check that
// - clazz is an interface
// - the implementation type implements clazz
// - clazz is annotated with @Mapper
//
// Use privileged action
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if ( classLoader == null ) {
classLoader = Mappers.class.getClassLoader();
}
@SuppressWarnings("unchecked")
T mapper = (T) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX ).newInstance();
return mapper;
}
catch ( Exception e ) {
throw new RuntimeException( e );
}
}
}

View File

@ -1,26 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>
* Provides the {@link org.mapstruct.factory.Mappers} factory class for the retrieval of mapper instances if no
* explicit component model such as CDI is configured via {@link org.mapstruct.Mapper#componentModel()}.
* </p>
*
*/
package org.mapstruct.factory;

View File

@ -1,31 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* <p>
* MapStruct is a code generator which simplifies the implementation of mappings between Java bean types by generating
* mapping code at compile time, following a convention-over-configuration approach. The generated code uses plain
* method invocations and thus is fast and type-safe.
* </p>
* <p>
* This package contains several annotations which allow to configure how mapper interfaces are generated.
* </p>
*
* @see <a href="http://mapstruct.org/">MapStruct reference documentation</a>
*/
package org.mapstruct;

View File

@ -1,40 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import static org.fest.assertions.Assertions.assertThat;
import org.junit.Test;
import org.mapstruct.factory.Mappers;
import org.mapstruct.test.model.Foo;
/**
* Unit test for {@link Mappers}.
*
* @author Gunnar Morling
*/
public class MappersTest {
@Test
public void shouldReturnImplementationInstance() {
Foo mapper = Mappers.getMapper( Foo.class );
assertThat( mapper ).isNotNull();
}
}

View File

@ -1,23 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.test.model;
public interface Foo {
}

View File

@ -1,23 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct.test.model;
public class FooImpl implements Foo {
}

View File

@ -1,22 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
and/or other contributors as indicated by the @authors tag. See the
copyright.txt file in the distribution for a full listing of all
contributors.
Copyright MapStruct Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@ -25,130 +12,18 @@
<parent>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0.0.Beta3</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<artifactId>mapstruct-jdk8</artifactId>
<packaging>jar</packaging>
<name>MapStruct Core JDK 8</name>
<description>MapStruct annotations to be used with JDK 8 and later</description>
<description>Deprecated MapStruct artifact containing annotations to be used with JDK 8 and later -
Relocated to mapstruct</description>
<distributionManagement>
<relocation>
<artifactId>mapstruct</artifactId>
</relocation>
</distributionManagement>
<properties>
<common.sources.dir>copied-common-sources</common.sources.dir>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mapstruct-common</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
<execution>
<id>check-style</id>
<phase>verify</phase>
<goals>
<goal>checkstyle</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-copied-common-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/${common.sources.dir}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${common.sources.dir}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/../core-common/src/main/java</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-mapstruct-license</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/classes/META-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/..</directory>
<filtering>false</filtering>
<include>LICENSE.txt</include>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,124 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Configures the mapping of one bean attribute or enum constant.
* <p>
* The name of the mapped attribute or constant is to be specified via {@link #target()}. For mapped bean attributes it
* is assumed by default that the attribute has the same name in the source bean. Alternatively, one of
* {@link #source()}, {@link #expression()} or {@link #constant()} can be specified to define the property source.
* <p>
* In addition, the attributes {@link #dateFormat()} and {@link #qualifiedBy()} may be used to further define the
* mapping.
*
* @author Gunnar Morling
*/
@Repeatable(Mappings.class)
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
public @interface Mapping {
/**
* The target name of the configured property as defined by the JavaBeans specification. The same target property
* must not be mapped more than once.
* <p>
* If used to map an enum constant, the name of the constant member is to be given. In this case, several values
* from the source enum may be mapped to the same value of the target enum.
*
* @return The target name of the configured property or enum constant
*/
String target();
/**
* The source to use for this mapping. This can either be:
* <ol>
* <li>The source name of the configured property as defined by the JavaBeans specification.
* <p>
* This may either be a simple property name (e.g. "address") or a dot-separated property path (e.g. "address.city"
* or "address.city.name"). In case the annotated method has several source parameters, the property name must
* qualified with the parameter name, e.g. "addressParam.city".</li>
* <li>When no matching property is found, MapStruct looks for a matching parameter name instead.</li>
* <li>When used to map an enum constant, the name of the constant member is to be given.</li>
* </ol>
* Either this attribute or {@link #constant()} or {@link #expression()} may be specified for a given mapping.
*
* @return The source name of the configured property or enum constant.
*/
String source() default "";
/**
* A format string as processable by {@link SimpleDateFormat} if the attribute is mapped from {@code String} to
* {@link Date} or vice-versa. Will be ignored for all other attribute types and when mapping enum constants.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
*/
String dateFormat() default "";
/**
* A constant {@link String} based on which the specified target property is to be set. If the designated target
* property is not of type {@code String}, the value will be converted by applying a matching conversion method or
* built-in conversion.
* <p>
* Either this attribute or {@link #source()} or {@link #expression()} may be specified for a given mapping.
*
* @return A constant {@code String} constant specifying the value for the designated target property
*/
String constant() default "";
/**
* An expression {@link String} based on which the specified target property is to be set. The format is determined
* by a type of expression. For instance:
* {@code expression = "java(new org.example.TimeAndFormat( s.getTime(), s.getFormat() ))")} will insert the java
* expression in the designated {@link #target()} property.
* <p>
* Either this attribute or {@link #source()} or {@link #constant()} may be specified for a given mapping.
*
* @return A constant {@code String} constant specifying the value for the designated target property
*/
String expression() default "";
/**
* Whether the property specified via {@link #target()} should be ignored by the generated mapping method or not.
* This can be useful when certain attributes should not be propagated from source or target or when properties in
* the target object are populated using a decorator and thus would be reported as unmapped target property by
* default.
*
* @return {@code true} if the given property should be ignored, {@code false} otherwise
*/
boolean ignore() default false;
/**
* A qualifier can be specified to aid the selection process of a suitable mapper. This is useful in case multiple
* mapping methods (hand written or generated) qualify and thus would result in an 'Ambiguous mapping methods found'
* error. A qualifier is a custom annotation and can be placed on a hand written mapper class or a method.
*
* @return the qualifiers
*/
Class<? extends Annotation>[] qualifiedBy() default { };
}

View File

@ -1,41 +0,0 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Configures the mappings of several bean attributes.
*
* @author Gunnar Morling
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
public @interface Mappings {
/**
* The configuration of the bean attributes.
*
* @return The configuration of the bean attributes.
*/
Mapping[] value();
}

View File

@ -1,22 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
and/or other contributors as indicated by the @authors tag. See the
copyright.txt file in the distribution for a full listing of all
contributors.
Copyright MapStruct Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@ -25,7 +12,7 @@
<parent>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-parent</artifactId>
<version>1.0.0.Beta3</version>
<version>1.7.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@ -33,24 +20,15 @@
<packaging>jar</packaging>
<name>MapStruct Core</name>
<properties>
<common.sources.dir>copied-common-sources</common.sources.dir>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mapstruct-common</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
@ -83,44 +61,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-copied-common-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/${common.sources.dir}</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${common.sources.dir}</outputDirectory>
<resources>
<resource>
<directory>${basedir}/../core-common/src/main/java</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-mapstruct-license</id>
<phase>prepare-package</phase>
@ -140,6 +84,27 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<Automatic-Module-Name>org.mapstruct</Automatic-Module-Name>
</instructions>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,97 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks a method to be invoked at the end of a generated mapping method, right before the last {@code return} statement
* of the mapping method. The method can be implemented in an abstract mapper class, be declared in a type (class or
* interface) referenced in {@link Mapper#uses()}, or in a type used as {@code @}{@link Context} parameter in order to
* be used in a mapping method.
* <p>
* The method invocation is only generated if the return type of the method (if non-{@code void}) is assignable to the
* return type of the mapping method and all parameters can be <em>assigned</em> by the available source, target or
* context parameters of the mapping method:
* <ul>
* <li>A parameter annotated with {@code @}{@link MappingTarget} is populated with the target instance of the mapping.
* </li>
* <li>A parameter annotated with {@code @}{@link TargetType} is populated with the target type of the mapping.</li>
* <li>Parameters annotated with {@code @}{@link Context} are populated with the context parameters of the mapping
* method.</li>
* <li>Any other parameter is populated with a source parameter of the mapping.</li>
* </ul>
* <p>
* For non-{@code void} methods, the return value of the method invocation is returned as the result of the mapping
* method if it is not {@code null}.
* <p>
* All <em>after-mapping</em> methods that can be applied to a mapping method will be used. {@code @}{@link Qualifier} /
* {@code @}{@link Named} can be used to filter the methods to use.
* <p>
* The order of the method invocation is determined by their location of definition:
* <ol>
* <li>Methods declared on {@code @}{@link Context} parameters, ordered by the parameter order.</li>
* <li>Methods implemented in the mapper itself.</li>
* <li>Methods from types referenced in {@link Mapper#uses()}, in the order of the type declaration in the annotation.
* </li>
* <li>Methods declared in one type are used after methods declared in their super-type</li>
* </ol>
* <em>Important:</em> the order of methods declared within one type can not be guaranteed, as it depends on the
* compiler and the processing environment implementation.
* <p>
* Example:
*
* <pre>
* <code>
* &#64;AfterMapping
* public void calledWithoutArgs() {
* // ...
* }
*
* &#64;AfterMapping
* public void calledWithSourceAndTargetType(SourceEntity anySource, &#64;TargetType Class&lt;?&gt; targetType) {
* // ...
* }
*
* &#64;AfterMapping
* public void calledWithSourceAndTarget(Object anySource, &#64;MappingTarget TargetDto target) {
* // ...
* }
*
* public abstract TargetDto toTargetDto(SourceEntity source);
*
* // generates:
*
* public TargetDto toTargetDto(SourceEntity source) {
* if ( source == null ) {
* return null;
* }
*
* TargetDto targetDto = new TargetDto();
*
* // actual mapping code
*
* calledWithoutArgs();
* calledWithSourceAndTargetType( source, TargetDto.class );
* calledWithSourceAndTarget( source, targetDto );
*
* return targetDto;
* }
* </code>
* </pre>
*
* @author Andreas Gudian
* @see BeforeMapping
* @see Context
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface AfterMapping {
}

View File

@ -0,0 +1,176 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
/**
* This can be used to have mapstruct generate additional annotations on classes/methods.
* <p>
* Examples based on the spring framework annotations.
* </p>
* Marking a class as `Lazy`:
*
* <pre><code>
* &#64;AnnotateWith( value = Lazy.class )
* &#64;Mapper
* public interface FooMapper {
* // mapper code
* }
* </code></pre>
*
* The following code would be generated:
*
* <pre><code>
* &#64;Lazy
* public class FooMapperImpl implements FooMapper {
* // mapper code
* }
* </code></pre>
* Setting the profile on the generated implementation:
*
* <pre><code>
* &#64;AnnotateWith( value = Profile.class, elements = @AnnotateWith.Element( strings = "prod" ) )
* &#64;Mapper
* public interface FooMapper {
* // mapper code
* }
* </code></pre>
*
* The following code would be generated:
*
* <pre><code>
* &#64;Profile( value = "prod" )
* public class FooMapperImpl implements FooMapper {
* // mapper code
* }
* </code></pre>
*
* @author Ben Zegveld
* @since 1.6
*/
@Repeatable( AnnotateWiths.class )
@Retention( CLASS )
@Target( { TYPE, METHOD, ANNOTATION_TYPE } )
public @interface AnnotateWith {
/**
* @return the annotation class that needs to be added.
*/
Class<? extends Annotation> value();
/**
* @return the annotation elements that are to be applied to this annotation.
*/
Element[] elements() default {};
/**
* Used in combination with {@link AnnotateWith} to configure the annotation elements. Only 1 value type may be used
* within the same annotation at a time. For example mixing shorts and ints is not allowed.
*
* @author Ben Zegveld
* @since 1.6
*/
@interface Element {
/**
* @return name of the annotation element.
*/
String name() default "value";
/**
* cannot be used in conjunction with other value fields.
*
* @return short value(s) for the annotation element.
*/
short[] shorts() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return byte value(s) for the annotation element.
*/
byte[] bytes() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return int value(s) for the annotation element.
*/
int[] ints() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return long value(s) for the annotation element.
*/
long[] longs() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return float value(s) for the annotation element.
*/
float[] floats() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return double value(s) for the annotation element.
*/
double[] doubles() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return char value(s) for the annotation element.
*/
char[] chars() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return boolean value(s) for the annotation element.
*/
boolean[] booleans() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return string value(s) for the annotation element.
*/
String[] strings() default {};
/**
* cannot be used in conjunction with other value fields.
*
* @return class value(s) for the annotation element.
*/
Class<?>[] classes() default {};
/**
* only used in conjunction with the {@link #enums()} annotation element.
*
* @return the class of the enum.
*/
Class<? extends Enum<?>> enumClass() default NullEnum.class;
/**
* cannot be used in conjunction with other value fields. {@link #enumClass()} is also required when using
* {@link #enums()}
*
* @return enum value(s) for the annotation element.
*/
String[] enums() default {};
}
}

View File

@ -0,0 +1,31 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
/**
* This can be used to have mapstruct generate additional annotations on classes/methods.
*
* @author Ben Zegveld
* @since 1.6
*/
@Retention( CLASS )
@Target( { TYPE, METHOD } )
public @interface AnnotateWiths {
/**
* The configuration of the additional annotations.
*
* @return The configuration of the additional annotations.
*/
AnnotateWith[] value();
}

View File

@ -0,0 +1,227 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.control.MappingControl;
import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR;
/**
* Configures the mapping between two bean types.
* <p>
* Unless otherwise specified these properties are inherited to the generated bean mapping methods.
* <p>
* Either {@link #resultType()}, {@link #qualifiedBy()} or {@link #nullValueMappingStrategy()} must be specified.
* </p>
* <p><strong>Example:</strong> Determining the result type</p>
* <pre><code class='java'>
* // When result types have an inheritance relation, selecting either mapping method {@link Mapping} or factory method
* // {@link BeanMapping} can be become ambiguous. Parameter {@link BeanMapping#resultType()} can be used.
* public class FruitFactory {
* public Apple createApple() {
* return new Apple();
* }
* public Orange createOrange() {
* return new Orange();
* }
* }
* &#64;Mapper(uses = FruitFactory.class)
* public interface FruitMapper {
* &#64;BeanMapping(resultType = Apple.class)
* Fruit toFruit(FruitDto fruitDto);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class FruitMapperImpl implements FruitMapper {
* &#64;Override
* public Fruit toFruit(FruitDto fruitDto) {
* Apple fruit = fruitFactory.createApple();
* // ...
* }
* }
* </code></pre>
*
* @author Sjaak Derksen
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface BeanMapping {
/**
* Specifies the result type of the factory method to be used in case several factory methods qualify.
* <p>
* <b>NOTE</b>: This property is not inherited to generated mapping methods
*
* @return the resultType to select
*/
Class<?> resultType() default void.class;
/**
* A qualifier can be specified to aid the selection process of a suitable factory method or filtering applicable
* {@code @}{@link BeforeMapping} / {@code @}{@link AfterMapping} methods. This is useful in case multiple factory
* method (hand written of internal) qualify and result in an 'Ambiguous factory methods' error.
* <p>
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
* @see Qualifier
*/
Class<? extends Annotation>[] qualifiedBy() default {};
/**
* Similar to {@link #qualifiedBy()}, but used in combination with {@code @}{@link Named} in case no custom
* qualifier annotation is defined.
*
* @return the qualifiers
* @see Named
*/
String[] qualifiedByName() default { };
/**
* The strategy to be applied when {@code null} is passed as source bean argument value to this bean mapping. If no
* strategy is configured, the strategy given via {@link MapperConfig#nullValueMappingStrategy()} or
* {@link Mapper#nullValueMappingStrategy()} will be applied, using {@link NullValueMappingStrategy#RETURN_NULL}
* by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when a source bean property is {@code null} or not present. If no strategy is
* configured, the strategy given via {@link MapperConfig#nullValuePropertyMappingStrategy()} or
* {@link Mapper#nullValuePropertyMappingStrategy()} will be applied,
* {@link NullValuePropertyMappingStrategy#SET_TO_NULL} will be used by default.
*
* @since 1.3
*
* @return The strategy to be applied when {@code null} is passed as source property value or the source property
* is not present.
*/
NullValuePropertyMappingStrategy nullValuePropertyMappingStrategy()
default NullValuePropertyMappingStrategy.SET_TO_NULL;
/**
* Determines when to include a null check on the source property value of a bean mapping.
*
* Can be overridden by the one on {@link MapperConfig}, {@link Mapper} or {@link Mapping}.
*
* @return strategy how to do null checking
*/
NullValueCheckStrategy nullValueCheckStrategy() default ON_IMPLICIT_CONVERSION;
/**
* Determines how to handle missing implementation for super classes when using the {@link SubclassMapping}.
*
* Overrides the setting on {@link MapperConfig} and {@link Mapper}.
*
* @return strategy to handle missing implementation combined with {@link SubclassMappings}.
*
* @since 1.5
*/
SubclassExhaustiveStrategy subclassExhaustiveStrategy() default COMPILE_ERROR;
/**
* Specifies the exception type to be thrown when a missing subclass implementation is detected
* in combination with {@link SubclassMappings}, based on the {@link #subclassExhaustiveStrategy()}.
* <p>
* This exception will only be thrown when the {@code subclassExhaustiveStrategy} is set to
* {@link SubclassExhaustiveStrategy#RUNTIME_EXCEPTION}.
*
* @return the exception class to throw when missing implementations are found.
* Defaults to {@link IllegalArgumentException}.
*/
Class<? extends Exception> subclassExhaustiveException() default IllegalArgumentException.class;
/**
* Default ignore all mappings. All mappings have to be defined manually. No automatic mapping will take place. No
* warning will be issued on missing source or target properties.
*
* @return The ignore strategy (default false).
*
* @since 1.3
*/
boolean ignoreByDefault() default false;
/**
* Unmapped source properties to be ignored. This could be used when {@link ReportingPolicy#WARN}
* or {@link ReportingPolicy#ERROR} is used for {@link Mapper#unmappedSourcePolicy()} or
* {@link MapperConfig#unmappedSourcePolicy()}. Listed properties will be ignored when composing the unmapped
* source properties report.
* <p>
* <b>NOTE</b>: This does not support ignoring nested source properties
* <p>
* <b>NOTE</b>: This property is not inherited to generated mapping methods
*
* @return The source properties that should be ignored when performing a report
*
* @since 1.3
*/
String[] ignoreUnmappedSourceProperties() default {};
/**
* How unmapped properties of the source type of a mapping should be reported.
* If no policy is configured, the policy given via {@link MapperConfig#unmappedSourcePolicy()} or
* {@link Mapper#unmappedSourcePolicy()} will be applied, using {@link ReportingPolicy#IGNORE} by default.
*
* @return The reporting policy for unmapped source properties.
*
* @since 1.6
*/
ReportingPolicy unmappedSourcePolicy() default ReportingPolicy.IGNORE;
/**
* How unmapped properties of the target type of a mapping should be reported.
* If no policy is configured, the policy given via {@link MapperConfig#unmappedTargetPolicy()} or
* {@link Mapper#unmappedTargetPolicy()} will be applied, using {@link ReportingPolicy#WARN} by default.
*
* @return The reporting policy for unmapped target properties.
*
* @since 1.5
*/
ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.WARN;
/**
* The information that should be used for the builder mappings. This can be used to define custom build methods
* for the builder strategy that one uses.
*
* If no builder is defined the builder given via {@link MapperConfig#builder()} or {@link Mapper#builder()}
* will be applied.
* <p>
* NOTE: In case no builder is defined here, in {@link Mapper} or {@link MapperConfig} and there is a single
* build method, then that method would be used.
* <p>
* If the builder is defined and there is a single method that does not match the name of the finisher than
* a compile error will occurs
*
* @return the builder information for the method level
*
* @since 1.3
*/
Builder builder() default @Builder;
/**
* Allows detailed control over the mapping process.
*
* @return the mapping control
*
* @since 1.4
*
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> mappingControl() default MappingControl.class;
}

View File

@ -0,0 +1,100 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks a method to be invoked at the beginning of a generated mapping method. The method can be implemented in an
* abstract mapper class, be declared in a type (class or interface) referenced in {@link Mapper#uses()}, or in a type
* used as {@code @}{@link Context} parameter in order to be used in a mapping method.
* <p>
* The method invocation is only generated if the return type of the method (if non-{@code void}) is assignable to the
* return type of the mapping method and all parameters can be <em>assigned</em> by the available source, target or
* context parameters of the mapping method:
* <ul>
* <li>A parameter annotated with {@code @}{@link MappingTarget} is populated with the target instance of the mapping.
* </li>
* <li>A parameter annotated with {@code @}{@link TargetType} is populated with the target type of the mapping.</li>
* <li>Parameters annotated with {@code @}{@link Context} are populated with the context parameters of the mapping
* method.</li>
* <li>Any other parameter is populated with a source parameter of the mapping.</li>
* </ul>
* <p>
* For non-{@code void} methods, the return value of the method invocation is returned as the result of the mapping
* method if it is not {@code null}.
* <p>
* All <em>before-mapping</em> methods that can be applied to a mapping method will be used. {@code @}{@link Qualifier}
* / {@code @}{@link Named} can be used to filter the methods to use.
* <p>
* The order of the method invocation is determined by their their variant and their location of definition:
* <ol>
* <li>Methods without an {@code @}{@link MappingTarget} parameter are called before any null-checks on source
* parameters and constructing a new target bean.</li>
* <li>Methods with an {@code @}{@link MappingTarget} parameter are called after constructing a new target bean.</li>
* <li>Methods declared on {@code @}{@link Context} parameters, ordered by the parameter order.</li>
* <li>Methods implemented in the mapper itself.</li>
* <li>Methods from types referenced in {@link Mapper#uses()}, in the order of the type declaration in the annotation.
* </li>
* <li>Methods declared in one type are used after methods declared in their super-type</li>
* </ol>
* <em>Important:</em> the order of methods declared within one type can not be guaranteed, as it depends on the
* compiler and the processing environment implementation.
* <p>
* Example:
*
* <pre>
* <code>
* &#64;BeforeMapping
* public void calledWithoutArgs() {
* // ...
* }
*
* &#64;BeforeMapping
* public void calledWithSourceAndTargetType(SourceEntity anySource, &#64;TargetType Class&lt;?&gt; targetType) {
* // ...
* }
*
* &#64;BeforeMapping
* public void calledWithSourceAndTarget(Object anySource, &#64;MappingTarget TargetDto target) {
* // ...
* }
*
* public abstract TargetDto toTargetDto(SourceEntity source);
*
* // generates:
*
* public TargetDto toTargetDto(SourceEntity source) {
* calledWithoutArgs();
* calledWithSourceAndTargetType( source, TargetDto.class );
*
* if ( source == null ) {
* return null;
* }
*
* TargetDto targetDto = new TargetDto();
*
* calledWithSourceAndTarget( source, targetDto );
*
* // actual mapping code
*
* return targetDto;
* }
* </code>
* </pre>
*
* @author Andreas Gudian
* @see AfterMapping
* @see Context
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface BeforeMapping {
}

View File

@ -0,0 +1,66 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.util.Experimental;
/**
* Configuration of builders, e.g. the name of the final build method.
*
* <p>
* <strong>Example:</strong> Using builder
* </p>
* <pre><code class='java'>
* // Mapper
* &#64;Mapper
* public interface SimpleBuilderMapper {
* &#64;Mapping(target = "name", source = "fullName"),
* &#64;Mapping(target = "job", constant = "programmer"),
* SimpleImmutablePerson toImmutable(SimpleMutablePerson source);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* &#64;Override
* public SimpleImmutablePerson toImmutable(SimpleMutablePerson source) {
* // name method can be changed with parameter {@link #buildMethod()}
* Builder simpleImmutablePerson = SimpleImmutablePerson.builder();
* simpleImmutablePerson.name( source.getFullName() );
* simpleImmutablePerson.age( source.getAge() );
* simpleImmutablePerson.address( source.getAddress() );
* simpleImmutablePerson.job( "programmer" );
* // ...
* }
* </code></pre>
*
* @author Filip Hrisafov
*
* @since 1.3
*/
@Retention(RetentionPolicy.CLASS)
@Target({})
@Experimental
public @interface Builder {
/**
* The name of the build method that needs to be invoked on the builder to create the type to be build
*
* @return the method that needs to tbe invoked on the builder
*/
String buildMethod() default "build";
/**
* Toggling builders on / off. Builders are sometimes used solely for unit testing (fluent testdata)
* MapStruct will need to use the regular getters /setters in that case.
*
* @return when true, no builder patterns will be applied
*/
boolean disableBuilder() default false;
}

View File

@ -0,0 +1,99 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for propagating the value of collection-typed properties from source to target.
* <p>
* In the table below, the dash {@code -} indicates a property name.
* Next, the trailing {@code s} indicates the plural form.
* The table explains the options and how they are applied to the presence / absence of a
* {@code set-s}, {@code add-} and / or {@code get-s} method on the target object.
* <table>
* <caption>Collection mapping strategy options</caption>
* <tr>
* <th>Option</th>
* <th>Only target set-s Available</th>
* <th>Only target add- Available</th>
* <th>Both set-s/add- Available</th>
* <th>No set-s/add- Available</th>
* <th>Existing Target ({@code @TargetType})</th>
* </tr>
* <tr>
* <td>{@link #ACCESSOR_ONLY}</td>
* <td>set-s</td>
* <td>get-s</td>
* <td>set-s</td>
* <td>get-s</td>
* <td>get-s</td>
* </tr>
* <tr>
* <td>{@link #SETTER_PREFERRED}</td>
* <td>set-s</td>
* <td>add-</td>
* <td>set-s</td>
* <td>get-s</td>
* <td>get-s</td>
* </tr>
* <tr>
* <td>{@link #ADDER_PREFERRED}</td>
* <td>set-s</td>
* <td>add-</td>
* <td>add-</td>
* <td>get-s</td>
* <td>get-s</td>
* </tr>
* <tr>
* <td>{@link #TARGET_IMMUTABLE}</td>
* <td>set-s</td>
* <td>exception</td>
* <td>set-s</td>
* <td>exception</td>
* <td>set-s</td>
* </tr>
* </table>
*
* @author Sjaak Derksen
*/
public enum CollectionMappingStrategy {
/**
* The setter of the target property will be used to propagate the value:
* {@code orderDto.setOrderLines(order.getOrderLines)}.
* <p>
* If no setter is available but a getter method, this will be used, under the assumption it has been initialized:
* {@code orderDto.getOrderLines().addAll(order.getOrderLines)}. This will also be the case when using
* {@link MappingTarget} (updating existing instances).
*/
ACCESSOR_ONLY,
/**
* If present, the setter of the target property will be used to propagate the value:
* {@code orderDto.setOrderLines(order.getOrderLines)}.
* <p>
* If no setter but and adder method is present, that adder will be invoked for each element of the source
* collection: {@code order.addOrderLine(orderLine() )}.
* <p>
* If neither a setter nor an adder method but a getter for the target property is present, that getter will be
* used, assuming it returns an initialized collection: If no setter is available, MapStruct will first look for an
* adder method before resorting to a getter.
*/
SETTER_PREFERRED,
/**
* Identical to {@link #SETTER_PREFERRED}, only that adder methods will be preferred over setter methods, if both
* are present for a given collection-typed property.
*/
ADDER_PREFERRED,
/**
* Identical to {@link #SETTER_PREFERRED}, however the target collection will not be cleared and accessed via
* addAll in case of updating existing bean instances, see: {@link MappingTarget}.
*
* Instead the target accessor (e.g. set) will be used on the target bean to set the collection.
*/
TARGET_IMMUTABLE;
}

View File

@ -0,0 +1,96 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation marks a method as a <em>presence check method</em> to check for presence in beans
* or it can be used to define additional check methods for something like source parameters.
* <p>
* By default, bean properties are checked against {@code null} or using a presence check method in the source bean.
* If a presence check method is available then it will be used instead.
* <p>
* Presence check methods have to return {@code boolean}.
* The following parameters are accepted for the presence check methods:
* <ul>
* <li>The parameter with the value of the source property.
* e.g. the value given by calling {@code getName()} for the name property of the source bean
* - only possible when using the {@link ConditionStrategy#PROPERTIES}
* </li>
* <li>The mapping source parameter</li>
* <li>{@code @}{@link Context} parameter</li>
* <li>
* {@code @}{@link TargetPropertyName} parameter -
* only possible when using the {@link ConditionStrategy#PROPERTIES}
* </li>
* <li>
* {@code @}{@link SourcePropertyName} parameter -
* only possible when using the {@link ConditionStrategy#PROPERTIES}
* </li>
* </ul>
*
* <strong>Note:</strong> The usage of this annotation is <em>mandatory</em>
* for a method to be considered as a presence check method.
*
* <pre><code class='java'>
* public class PresenceCheckUtils {
*
* &#64;Condition
* public static boolean isNotEmpty(String value) {
* return value != null &#38;&#38; !value.isEmpty();
* }
* }
*
* &#64;Mapper(uses = PresenceCheckUtils.class)
* public interface MovieMapper {
*
* MovieDto map(Movie movie);
* }
* </code></pre>
* <p>
* The following implementation of {@code MovieMapper} will be generated:
*
* <pre><code class='java'>
* public class MovieMapperImpl implements MovieMapper {
*
* &#64;Override
* public MovieDto map(Movie movie) {
* if ( movie == null ) {
* return null;
* }
*
* MovieDto movieDto = new MovieDto();
*
* if ( PresenceCheckUtils.isNotEmpty( movie.getTitle() ) ) {
* movieDto.setTitle( movie.getTitle() );
* }
*
* return movieDto;
* }
* }
* </code></pre>
* <p>
* This annotation can also be used as a meta-annotation to define the condition strategy.
*
* @author Filip Hrisafov
* @see SourceParameterCondition
* @since 1.5
*/
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.CLASS)
public @interface Condition {
/**
* @return the places where the condition should apply to
* @since 1.6
*/
ConditionStrategy[] appliesTo() default ConditionStrategy.PROPERTIES;
}

View File

@ -0,0 +1,23 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for defining what to what a condition (check) method is applied to
*
* @author Filip Hrisafov
* @since 1.6
*/
public enum ConditionStrategy {
/**
* The condition method should be applied whether a property should be mapped.
*/
PROPERTIES,
/**
* The condition method should be applied to check if a source parameters should be mapped.
*/
SOURCE_PARAMETERS,
}

View File

@ -0,0 +1,181 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks a parameter of a method to be treated as <em>mapping context</em>. Such parameters are passed to other mapping
* methods, {@code @}{@link ObjectFactory} methods or {@code @}{@link BeforeMapping}/{@code @}{@link AfterMapping}
* methods when applicable and can thus be used in custom code.
* <p>
* The type of an {@code @Context} parameter is also inspected for
* {@code @}{@link BeforeMapping}/{@code @}{@link AfterMapping} methods, which are called on the provided context
* parameter value if applicable.
* <p>
* <strong>Note:</strong> no {@code null} checks are performed before calling before/after mapping methods or object
* factory methods on {@code @}{@link Context} annotated parameters. The caller needs to make sure that no {@code null}
* are passed in that case.
* <p>
* For generated code to call a method that is declared with {@code @Context} parameters, the declaration of the mapping
* method being generated needs to contain at least those (or assignable) {@code @Context} parameters as well. MapStruct
* will not create new instances of missing {@code @Context} parameters nor will it pass {@code null} instead.
* <p>
* <strong>Example 1:</strong> Using {@code @Context} parameters for passing data down to hand-written property mapping
* methods and {@code @}{@link BeforeMapping} methods:
*
* <pre>
* <code>
* // multiple &#64;Context parameters can be added
* public abstract CarDto toCar(Car car, &#64;Context VehicleRegistration context, &#64;Context Locale localeToUse);
*
* protected OwnerManualDto translateOwnerManual(OwnerManual ownerManual, &#64;Context Locale locale) {
* // manually implemented logic to translate the OwnerManual with the given Locale
* }
*
* &#64;BeforeMapping
* protected void registerVehicle(Vehicle mappedVehicle, &#64;Context VehicleRegistration context) {
* context.register( mappedVehicle );
* }
*
* &#64;BeforeMapping
* protected void notCalled(Vehicle mappedVehicle, &#64;Context DifferentMappingContextType context) {
* // not called, because no context parameter of type DifferentMappingContextType is available
* // within toCar(Car, VehicleRegistration, Locale)
* }
*
* // generates:
*
* public CarDto toCar(Car car, VehicleRegistration context, Locale localeToUse) {
* registerVehicle( car, context );
*
* if ( car == null ) {
* return null;
* }
*
* CarDto carDto = new CarDto();
*
* carDto.setOwnerManual( translateOwnerManual( car.getOwnerManual(), localeToUse );
* // more generated mapping code
*
* return carDto;
* }
* </code>
* </pre>
* <p>
* <strong>Example 2:</strong> Using an {@code @Context} parameter with a type that provides its own {@code @}
* {@link BeforeMapping} methods to handle cycles in Graph structures:
*
* <pre>
* <code>
* // type of the context parameter
* public class CyclicGraphContext {
* private Map&lt;Object, Object&gt; knownInstances = new IdentityHashMap&lt;&gt;();
*
* &#64;BeforeMapping
* public &lt;T extends NodeDto&gt; T getMappedInstance(Object source, &#64;TargetType Class&lt;T&gt; targetType) {
* return (T) knownInstances.get( source );
* }
*
* &#64;BeforeMapping
* public void storeMappedInstance(Object source, &#64;MappingTarget NodeDto target) {
* knownInstances.put( source, target );
* }
* }
*
* &#64;Mapper
* public interface GraphMapper {
* NodeDto toNodeDto(Node node, &#64;Context CyclicGraphContext cycleContext);
* }
*
*
* // generates:
*
* public NodeDto toNodeDto(Node node, CyclicGraphContext cycleContext) {
* NodeDto target = cycleContext.getMappedInstance( node, NodeDto.class );
* if ( target != null ) {
* return target;
* }
*
* if ( node == null ) {
* return null;
* }
*
* NodeDto nodeDto = new NodeDto();
*
* cycleContext.storeMappedInstance( node, nodeDto );
*
* nodeDto.setParent( toNodeDto( node.getParent(), cycleContext ) );
* List&lt;NodeDto&gt; list = nodeListToNodeDtoList( node.getChildren(), cycleContext );
* if ( list != null ) {
* nodeDto.setChildren( list );
* }
*
* // more mapping code
*
* return nodeDto;
* }
* </code>
* </pre>
* <p>
* <strong>Example 3:</strong> Using {@code @Context} parameters for creating an entity object by calling an
* {@code @}{@link ObjectFactory} methods:
*
* <pre>
* <code>
* // type of the context parameter
* public class ContextObjectFactory {
* &#64;PersistenceContext(unitName = "my-unit")
* private EntityManager em;
*
* &#64;ObjectFactory
* public Valve create( String id ) {
* Query query = em.createNamedQuery("Valve.findById");
* query.setParameter("id", id);
* Valve result = query.getSingleResult();
* if ( result != null ) {
* result = new Valve( id );
* }
* return result;
* }
*
* }
*
* &#64;Mapper
* public interface ContextWithObjectFactoryMapper {
* Valve map(ValveDto dto, &#64;Context ContextObjectFactory factory, String id);
* }
*
*
* // generates:
* public class ContextWithObjectFactoryMapperImpl implements ContextWithObjectFactoryMapper {
*
* &#64;Override
* public Valve map(ValveDto dto, ContextObjectFactory factory, String id) {
* if ( dto == null ) {
* return null;
* }
*
* Valve valve = factory.create( id );
*
* valve.setOneWay( dto.isOneWay() );
*
* return valve;
* }
* }
* </code>
* </pre>
* @author Andreas Gudian
* @since 1.2
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface Context {
}

View File

@ -0,0 +1,160 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Specifies a decorator to be applied to a generated mapper, which e.g. can be used to amend mappings performed by
* generated mapping methods.
* <p>
* A typical decorator implementation will be an abstract class and only implement/override a subset of the methods of
* the mapper type which it decorates. All methods not implemented or overridden by the decorator will be implemented by
* the code generator by delegating to the generated mapper implementation.
* <p>
* <b>NOTE:</b> The usage of decorated mappers differs depending on the selected component model.
* <p>
* <b>NOTE:</b> This annotation is not supported for the component model {@code cdi}. Use CDI's own
* <a href="https://docs.jboss.org/cdi/spec/1.0/html/decorators.html">{@code @Decorator}</a> feature instead.
* </p>
* <h2>Examples</h2>
* <p>
* For the examples below, consider the following mapper declaration:
*
* <pre>
* &#64;Mapper(componentModel = "...")
* &#64;DecoratedWith(PersonMapperDecorator.class)
* public interface PersonMapper {
*
* &#64;Mapping(target = "name", ignore = true)
* PersonDto personToPersonDto(Person person);
*
* AddressDto addressToAddressDto(Address address); // not touched by the decorator
* }
* </pre>
*
* <h3>1. Component model 'default'</h3>
* <h4>Referencing the original mapper in the decorator</h4>
* <p>
* If a constructor with a single parameter accepting the type of the decorated mapper is present, a delegate with
* generated implementations of all the mapper methods will be passed to this constructor. A typical implementation will
* store the passed delegate in a field of the decorator and make use of it in the decorator methods:
*
* <pre>
* public abstract class PersonMapperDecorator implements PersonMapper {
*
* private PersonMapper delegate;
*
* public PersonMapperDecorator(PersonMapper delegate) {
* this.delegate = delegate;
* }
*
* &#64;Override
* public PersonDto personToPersonDto(Person person) {
* PersonDto dto = delegate.personToPersonDto( person );
* dto.setName( person.getFirstName() + " " + person.getLastName() );
*
* return dto;
* }
* }
* </pre>
*
* <h4>Using the decorated mapper</h4>
* <p>
* Nothing special needs to be done. When using {@code Mappers.getMapper( PersonMapper.class )}, the <em>decorator</em>
* is returned, with the injected original mapper.
* <h3>2. Component model 'spring'</h3>
* <h4>Referencing the original mapper in the decorator</h4>
* <p>
* The generated implementation of the original mapper is annotated with the Spring annotation
* {@code @org.springframework.beans.factory.annotation.Qualifier("delegate")}. To autowire that bean in your decorator,
* add that qualifier annotation as well:
*
* <pre>
* public abstract class PersonMapperDecorator implements PersonMapper {
*
* &#64;Autowired
* &#64;org.springframework.beans.factory.annotation.Qualifier("delegate")
* private PersonMapper delegate;
*
* &#64;Override
* public PersonDto personToPersonDto(Person person) {
* PersonDto dto = delegate.personToPersonDto( person );
* dto.setName( person.getFirstName() + " " + person.getLastName() );
*
* return dto;
* }
* }
* </pre>
*
* <h4>Using the decorated mapper in the decorator</h4>
* <p>
* The generated class that extends the decorator is annotated with Spring's {@code @Primary} annotation. To autowire
* the decorated mapper in the application, nothing special needs to be done:
*
* <pre>
* &#64;Autowired
* private PersonMapper personMapper; // injects the decorator, with the injected original mapper
* </pre>
*
* <h3>3. Component model 'jsr330' or 'jakarta'</h3>
* <h4>Referencing the original mapper</h4>
* <p>
* JSR 330 / Jakarta Inject doesn't specify qualifiers and only allows to specifically name the beans. Hence,
* the generated implementation of the original mapper is annotated with
* {@code @Named("fully-qualified-name-of-generated-impl")} and {@code @Singleton} (please note that when
* using a decorator, the class name of the mapper implementation ends with an underscore). To inject that bean in your
* decorator, add the same annotation to the delegate field (e.g. by copy/pasting it from the generated class):
*
* <pre>
* public abstract class PersonMapperDecorator implements PersonMapper {
*
* &#64;Inject
* &#64;javax.inject.Named("org.examples.PersonMapperImpl_")
* private PersonMapper delegate;
*
* &#64;Override
* public PersonDto personToPersonDto(Person person) {
* PersonDto dto = delegate.personToPersonDto( person );
* dto.setName( person.getFirstName() + " " + person.getLastName() );
*
* return dto;
* }
* }
* </pre>
*
* <h4>Using the decorated mapper in the decorator</h4>
* <p>
* Unlike with the other component models, the usage site must be aware if a mapper is decorated or not, as for
* decorated mappers, the parameterless {@code @javax.inject.Named} annotation must be added to select the
* <em>decorator</em> to be injected:
*
* <pre>
* &#64;Inject
* &#64;javax.inject.Named
* private PersonMapper personMapper; // injects the decorator, with the injected original mapper
* </pre>
* <p>
*
* @author Gunnar Morling
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface DecoratedWith {
/**
* The decorator type. Must be an abstract class that extends or implements the mapper type to which it is applied.
* <p>
* For component-model {@code default}, the decorator type must either have a default constructor or a constructor
* with a single parameter accepting the type of the decorated mapper.
*
* @return the decorator type
*/
Class<?> value();
}

View File

@ -0,0 +1,156 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Configured the mapping between two value types.
* <p><strong>Example:</strong> Using a suffix for enums</p>
* <pre><code class='java'>
* public enum CheeseType {
* BRIE,
* ROQUEFORT
* }
*
* public enum CheeseTypeSuffixed {
* BRIE_TYPE,
* ROQUEFORT_TYPE
* }
*
* &#64;Mapper
* public interface CheeseMapper {
*
* &#64;EnumMapping(nameTransformationStrategy = "suffix", configuration = "_TYPE")
* CheeseTypeSuffixed map(Cheese cheese);
*
* &#64;InheritInverseConfiguration
* Cheese map(CheeseTypeSuffixed cheese);
*
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class CheeseMapperImpl implements CheeseMapper {
*
* &#64;Override
* public CheeseTypeSuffixed map(Cheese cheese) {
* if ( cheese == null ) {
* return null;
* }
*
* CheeseTypeSuffixed cheeseTypeSuffixed;
*
* switch ( cheese ) {
* case BRIE:
* cheeseTypeSuffixed = CheeseTypeSuffixed.BRIE_TYPE;
* break;
* case ROQUEFORT:
* cheeseTypeSuffixed = CheeseTypeSuffixed.ROQUEFORT_TYPE;
* break;
* default:
* throw new IllegalArgumentException( "Unexpected enum constant: " + cheese );
* }
*
* return cheeseTypeSuffixed;
* }
*
* &#64;Override
* public Cheese map(CheeseTypeSuffixed cheese) {
* if ( cheese == null ) {
* return null;
* }
*
* CheeseType cheeseType;
*
* switch ( cheese ) {
* case BRIE_TYPE:
* cheeseType = CheeseType.BRIE;
* break;
* case ROQUEFORT_TYPE:
* cheeseType = CheeseType.ROQUEFORT;
* break;
* default:
* throw new IllegalArgumentException( "Unexpected enum constant: " + cheese );
* }
*
* return cheeseType;
* }
* }
* </code></pre>
*
* @author Filip Hrisafov
* @since 1.4
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface EnumMapping {
/**
* Specifies the name transformation strategy that should be used for implicit mapping between enums.
* Known strategies are:
* <ul>
* <li>{@link MappingConstants#SUFFIX_TRANSFORMATION} - applies the given {@link #configuration()} as a
* suffix to the source enum</li>
* <li>{@link MappingConstants#STRIP_SUFFIX_TRANSFORMATION} - strips the given {@link #configuration()}
* from the end of the source enum</li>
* <li>{@link MappingConstants#PREFIX_TRANSFORMATION} - applies the given {@link #configuration()} as a
* prefix to the source enum</li>
* <li>{@link MappingConstants#STRIP_PREFIX_TRANSFORMATION} - strips the given {@link #configuration()} from
* the start of the source enum</li>
* <li>
* {@link MappingConstants#CASE_TRANSFORMATION} - applies the given {@link #configuration()} case
* transformation to the source enum. Supported configurations are:
* <ul>
* <li><i>upper</i> - Performs upper case transformation to the source enum</li>
* <li><i>lower</i> - Performs lower case transformation to the source enum</li>
* <li>
* <i>capital</i> - Performs capitalisation of the first character of every word in the source enum
* and everything else to lower case. A word is split by "_".
* </li>
* </ul>
* </li>
* </ul>
*
* It is possible to use custom name transformation strategies by implementing the {@code
* EnumTransformationStrategy} SPI.
*
* @return the name transformation strategy
*/
String nameTransformationStrategy() default "";
/**
* The configuration that should be passed on the appropriate name transformation strategy.
* e.g. a suffix that should be applied to the source enum when doing name based mapping.
*
* @return the configuration to use
*/
String configuration() default "";
/**
* Exception that should be thrown by the generated code if no mapping matches.
* If no exception is configured, the exception given via {@link MapperConfig#unexpectedValueMappingException()} or
* {@link Mapper#unexpectedValueMappingException()} will be used, using {@link IllegalArgumentException} by default.
*
* <p>
* Note:
* <ul>
* <li>
* The defined exception should at least have a constructor with a {@link String} parameter.
* </li>
* <li>
* If the defined exception is a checked exception then the enum mapping methods should have that exception
* in the throws clause.
* </li>
* </ul>
*
* @return the exception that should be used in the generated code
*/
Class<? extends Exception> unexpectedValueMappingException() default IllegalArgumentException.class;
}

View File

@ -0,0 +1,67 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Configures the ignored of one bean attribute.
*
* <p>
* The name all attributes of for ignored is to be specified via {@link #targets()}.
* </p>
*
* <p>
* <strong>Example 1:</strong> Implicitly mapping fields with the same name:
* </p>
*
* <pre><code class='java'>
* // We need ignored Human.name and Human.lastName
* // we can use &#64;Ignored with parameters "name", "lastName" {@link #targets()}
* &#64;Mapper
* public interface HumanMapper {
* &#64;Ignored( targets = { "name", "lastName" } )
* HumanDto toHumanDto(Human human)
* }
* </code></pre>
* <pre><code class='java'>
* // generates:
* &#64;Override
* public HumanDto toHumanDto(Human human) {
* humanDto.setFullName( human.getFullName() );
* // ...
* }
* </code></pre>
*
* @author Ivashin Aleksey
*/
@Repeatable(IgnoredList.class)
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
public @interface Ignored {
/**
* Whether the specified properties should be ignored by the generated mapping method.
* This can be useful when certain attributes should not be propagated from source to target or when properties in
* the target object are populated using a decorator and thus would be reported as unmapped target property by
* default.
*
* @return The target names of the configured properties that should be ignored
*/
String[] targets();
/**
* The prefix that should be applied to all the properties specified via {@link #targets()}.
*
* @return The target prefix to be applied to the defined properties
*/
String prefix() default "";
}

View File

@ -0,0 +1,54 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Configures the ignored list for several bean attributes.
* <p>
* <strong>TIP: When using Java 8 or later, you can omit the {@code @IgnoredList}
* wrapper annotation and directly specify several {@code @Ignored} annotations on one method.</strong>
*
* <p>These two examples are equal.
* </p>
* <pre><code class='java'>
* // before Java 8
* &#64;Mapper
* public interface MyMapper {
* &#64;IgnoredList({
* &#64;Ignored(targets = { "firstProperty" } ),
* &#64;Ignored(targets = { "secondProperty" } )
* })
* HumanDto toHumanDto(Human human);
* }
* </code></pre>
* <pre><code class='java'>
* // Java 8 and later
* &#64;Mapper
* public interface MyMapper {
* &#64;Ignored(targets = { "firstProperty" } ),
* &#64;Ignored(targets = { "secondProperty" } )
* HumanDto toHumanDto(Human human);
* }
* </code></pre>
*
* @author Ivashin Aleksey
*/
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE })
public @interface IgnoredList {
/**
* The configuration of the bean attributes.
*
* @return The configuration of the bean attributes.
*/
Ignored[] value();
}

View File

@ -0,0 +1,54 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Advises the code generator to apply the configuration (as given via {@link Mapping}, {@link IterableMapping} etc.)
* from another mapping method (declared on the same mapper type) or prototype method (declared on a mapper config class
* referenced via {@link Mapper#config()}) to the annotated method as well.
* <p>
* If no method can be identified unambiguously as configuration source (i.e. several candidate methods with matching
* source and target type exist), the name of the method to inherit from must be specified via {@link #name()}.
* <p>
* {@link Mapping#expression()}, {@link Mapping#constant()}, {@link Mapping#defaultExpression()} and
* {@link Mapping#defaultValue()} are not inverse inherited
*
* <p>
* A typical use case is annotating an update method so it inherits all mappings from a corresponding "standard" mapping
* method:
*
* <pre>
* <code>
* &#64;Mappings({
* &#64;Mapping(target="make", source="brand"),
* &#64;Mapping(target="seatCount", source="numberOfSeats")
* })
* CarDto carToCarDto(Car car);
*
* &#64;InheritConfiguration
* void updateCarDto(Car car, &#64;MappingTarget CarDto carDto);
* </code>
* </pre>
*
* @author Sjaak Derksen
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface InheritConfiguration {
/**
* The name of the mapping method to inherit the mappings from. Needs only to be specified in case more than one
* method with matching source and target type exists.
*
* @return The name of the mapping method to inherit the mappings from.
*/
String name() default "";
}

View File

@ -0,0 +1,90 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Advises the code generator to apply all the {@link Mapping}s from an inverse mapping method to the annotated method
* as well. An inverse mapping method is a method which has the annotated method's source type as target type (return
* type or indicated through a parameter annotated with {@link MappingTarget}) and the annotated method's target type as
* source type.
* <p>
* Any mappings given on the annotated method itself are added to those mappings inherited from the inverse method. In
* case of a conflict local mappings take precedence over inherited mappings.
* <p>
* If more than one matching inverse method exists, the name of the method to inherit the configuration from must be
* specified via {@link #name()}
* <p>
* {@link Mapping#expression()}, {@link Mapping#constant()}, {@link Mapping#defaultExpression()} and
* {@link Mapping#defaultValue()} are not inverse inherited
*
* <p>
* <strong>Examples</strong>
* </p>
* <pre><code class='java'>
* &#64;Mapper
* public interface HumanMapper {
* Human toHuman(HumanDto humanDto);
* &#64;InheritInverseConfiguration
* HumanDto toHumanDto(Human human);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class HumanMapperImpl implements HumanMapper {
* &#64;Override
* public Human toHuman(HumanDto humanDto) {
* if ( humanDto == null ) {
* return null;
* }
* Human human = new Human();
* human.setName( humanDto.getName() );
* return human;
* }
* &#64;Override
* public HumanDto toHumanDto(Human human) {
* if ( human == null ) {
* return null;
* }
* HumanDto humanDto = new HumanDto();
* humanDto.setName( human.getName() );
* return humanDto;
* }
* }
* </code></pre>
*
* <pre><code class='java'>
* &#64;Mapper
* public interface CarMapper {
*
* &#64;Mapping( target = "seatCount", source = "numberOfSeats")
* &#64;Mapping( target = "enginePower", source = "engineClass", ignore=true) // NOTE: source specified as well
* CarDto carToDto(Car car);
*
* &#64;InheritInverseConfiguration
* &#64;Mapping(target = "numberOfSeats", ignore = true)
* // no need to specify a mapping with ignore for "engineClass": specifying source above will assume
* Car carDtoToCar(CarDto carDto);
* }
* </code></pre>
* @author Sjaak Derksen
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface InheritInverseConfiguration {
/**
* The name of the inverse mapping method to inherit the mappings from. Needs to be specified only in case more than
* one inverse method exists with a matching source and target type exists.
*
* @return The name of the inverse mapping method to inherit the mappings from.
*/
String name() default "";
}

View File

@ -0,0 +1,25 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for handling injection. This is only used on annotated based component models such as CDI, Spring and
* JSR330 / Jakarta.
*
* @author Kevin Grüneberg
* @author Lucas Resch
*/
public enum InjectionStrategy {
/** Annotations are written on the field **/
FIELD,
/** Annotations are written on the constructor **/
CONSTRUCTOR,
/** A dedicated setter method is created */
SETTER
}

View File

@ -0,0 +1,159 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.mapstruct.control.MappingControl;
/**
* Configures the mapping between two iterable like types, e.g. {@code List<String>} and {@code List<Date>}.
*
*
* <p>Note: either {@link #dateFormat()}, {@link #elementTargetType()} or {@link #qualifiedBy() }
* must be specified</p>
*
* <p>
* <strong>Example:</strong> Convert List&lt;Float&gt; to List&lt;String&gt;
* </p>
* <pre><code class='java'>
* &#64;Mapper
* public interface FloatToStringMapper {
* &#64;IterableMapping( numberFormat = "##.00" )
* List&lt;String&gt; sourceToTarget(List&lt;Float&gt; source);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class FloatToStringMapperImpl implements FloatToStringMapper {
* &#64;Override
* public List&lt;String&gt; sourceToTarget(List&lt;Float&gt; source) {
* List&lt;String&gt; list = new ArrayList&lt;String&gt;( source.size() );
* for ( Float float1 : source ) {
* list.add( new DecimalFormat( "##.00" ).format( float1 ) );
* }
* // ...
* }
* }
* </code></pre>
*
* Supported mappings are:
* <ul>
* <li>{@code Iterable<A>} to/from {@code Iterable<B>}/{@code Iterable<A>}</li>
* <li>{@code Iterable<A>} to/from {@code B[]}/{@code A[]}</li>
* <li>{@code Iterable<A>} to/from {@code Stream<B>}/{@code Stream<A>}</li>
* <li>{@code A[]} to/from {@code Stream<B>}/{@code Stream<A>}</li>
* <li>{@code A[]} to/from {@code B[]}</li>
* <li>{@code Stream<A>} to/from {@code Stream<B>}</li>
* </ul>
*
* @author Gunnar Morling
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface IterableMapping {
/**
* A format string as processable by {@link SimpleDateFormat} if the annotated method maps from an iterable of
* {@code String} to an iterable {@link Date} or vice-versa. Will be ignored for all other element types.
* <p>
* If the {@link #locale()} is also specified, the format will consider the specified locale when processing
* the date. Otherwise, the system's default locale will be used.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
* @see #locale()
*/
String dateFormat() default "";
/**
* A format string as processable by {@link DecimalFormat} if the annotated method maps from a
* {@link Number} to a {@link String} or vice-versa. Will be ignored for all other element types.
* <p>
* If the {@link #locale()} is also specified, the number format will be applied in the context of the given locale.
* Otherwise, the system's default locale will be used to process the number format.
*
* @return A decimal format string as processable by {@link DecimalFormat}.
* @see #locale()
*/
String numberFormat() default "";
/**
* Specifies the locale to be used when processing {@link #dateFormat()} or {@link #numberFormat()}.
* <p>
* The locale should be a plain tag representing the language, such as "en" for English, "de" for German, etc.
* <p>
* If no locale is specified, the system's default locale will be used.
*
* @return A string representing the locale to be used when formatting dates or numbers.
*/
String locale() default "";
/**
* A qualifier can be specified to aid the selection process of a suitable mapper. This is useful in case multiple
* mappers (hand written of internal) qualify and result in an 'Ambiguous mapping methods found' error.
*
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
* @see Qualifier
*/
Class<? extends Annotation>[] qualifiedBy() default { };
/**
* String-based form of qualifiers; When looking for a suitable mapping method to map this iterable mapping method's
* element type, MapStruct will only consider those methods carrying directly or indirectly (i.e. on the
* class-level) a {@link Named} annotation for each of the specified qualifier names.
* <p>
* Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and
* are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large
* number of qualifiers as no custom annotation types are needed.
*
* @return One or more qualifier name(s)
* @see #qualifiedBy()
* @see Named
*/
String[] qualifiedByName() default { };
/**
* Specifies the type of the element to be used in the result of the mapping method in case multiple mapping
* methods qualify.
*
* @return the elementTargetType to select
*/
Class<?> elementTargetType() default void.class;
/**
* The strategy to be applied when {@code null} is passed as source value to this iterable mapping. If no
* strategy is configured, the strategy given via {@link MapperConfig#nullValueMappingStrategy()} or
* {@link Mapper#nullValueMappingStrategy()} will be applied, using {@link NullValueMappingStrategy#RETURN_NULL}
* by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* Allows detailed control over the mapping process.
*
* @return the mapping control
*
* @since 1.4
*
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> elementMappingControl() default MappingControl.class;
}

View File

@ -0,0 +1,115 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Allows the definition of Javadoc comments in the MapStruct <code>Mapper</code> generated class.
*
* <p>The annotation provides support for the usual Javadoc comments elements by defining analogous attributes.</p>
*
*
* <p>Please, note that at least one of these attributes must be specified.</p>
*
* <p>
* For instance, the following definition;
* </p>
* <pre><code class='java'>
* &#64;Javadoc(
* value = "This is the description",
* authors = { "author1", "author2" },
* deprecated = "Use {&#64;link OtherMapper} instead",
* since = "0.1"
* )
* </code></pre>
*
* <p>
* will generate:
* </p>
*
* <pre><code class='java'>
* /**
* * This is the description
* *
* * &#64;author author1
* * &#64;author author2
* *
* * &#64;deprecated Use {&#64;link OtherMapper} instead
* * &#64;since 0.1
* *&#47;
* </code></pre>
*
* <p>
* The entire Javadoc comment block can be passed directly:
* </p>
* <pre><code class='java'>
* &#64;Javadoc("This is the description\n"
* + "\n"
* + "&#64;author author1\n"
* + "&#64;author author2\n"
* + "\n"
* + "&#64;deprecated Use {&#64;link OtherMapper} instead\n"
* + "&#64;since 0.1\n"
* )
* </code></pre>
*
* <pre><code class='java'>
* // or using Text Blocks
* &#64;Javadoc(
* """
* This is the description
*
* &#64;author author1
* &#64;author author2
*
* &#64;deprecated Use {&#64;link OtherMapper} instead
* &#64;since 0.1
* """
* )
* </code></pre>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Javadoc {
/**
* Main Javadoc comment text block.
*
* @return Main Javadoc comment text block.
*/
String value() default "";
/**
* List of authors of the code that it is being documented.
* <p>
* It will generate a list of the Javadoc tool comment element <code>&#64;author</code>
* with the different values and in the order provided.
*
* @return array of javadoc authors.
*/
String[] authors() default { };
/**
* Specifies that the functionality that is being documented is deprecated.
* <p>
* Corresponds to the <code>&#64;deprecated</code> Javadoc tool comment element.
*
* @return Deprecation message about the documented functionality
*/
String deprecated() default "";
/**
* Specifies the version since the functionality that is being documented is available.
* <p>
* Corresponds to the <code>&#64;since</code> Javadoc tool comment element.
*
* @return Version since the functionality is available
*/
String since() default "";
}

View File

@ -0,0 +1,227 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.mapstruct.control.MappingControl;
/**
* Configures the mapping between two map types, e.g. Map&lt;String, String&gt; and Map&lt;Long, Date&gt;.
*
* <p>
* <strong>Example</strong>:
* </p>
* <pre><code class='java'>
* &#64;Mapper
* public interface SimpleMapper {
* &#64;MapMapping(valueDateFormat = "dd.MM.yyyy")
* Map&lt;String, String&gt; longDateMapToStringStringMap(Map&lt;Long, Date&gt; source);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class SimpleMapperImpl implements SimpleMapper {
* &#64;Override
* public Map&lt;String, String&gt; longDateMapToStringStringMap(Map&lt;Long, Date&gt; source) } {
* Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); }
* for ( java.util.Map.Entry&lt;Long, Date&gt; entry : source.entrySet() ) } {
* String key = new DecimalFormat( "" ).format( entry.getKey() );
* String value = new SimpleDateFormat( "dd.MM.yyyy" ).format( entry.getValue() );
* map.put( key, value );
* }
* // ...
* }
* }
* </code></pre>
*
* <p><strong>NOTE:</strong> at least one element needs to be specified</p>
*
* @author Gunnar Morling
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
public @interface MapMapping {
/**
* A format string as processable by {@link SimpleDateFormat} if the annotated method maps from a map with key type
* {@code String} to an map with key type {@link Date} or vice-versa. Will be ignored for all other key types.
* <p>
* If the {@link #locale()} is specified, the format will consider the specified locale when processing the date.
* Otherwise, the system's default locale will be used.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
* @see #locale()
*/
String keyDateFormat() default "";
/**
* A format string as processable by {@link SimpleDateFormat} if the annotated method maps from a map with value
* type {@code String} to an map with value type {@link Date} or vice-versa. Will be ignored for all other value
* types.
* <p>
* If the {@link #locale()} is specified, the format will consider the specified locale when processing the date.
* Otherwise, the system's default locale will be used.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
* @see #locale()
*/
String valueDateFormat() default "";
/**
* A format string as processable by {@link DecimalFormat} if the annotated method maps from a
* {@link Number} to a {@link String} or vice-versa. Will be ignored for all other key types.
* <p>
* If the {@link #locale()} is specified, the number format will be applied in the context of the given locale.
* Otherwise, the system's default locale will be used.
*
* @return A decimal format string as processable by {@link DecimalFormat}.
* @see #locale()
*/
String keyNumberFormat() default "";
/**
* A format string as processable by {@link DecimalFormat} if the annotated method maps from a
* {@link Number} to a {@link String} or vice-versa. Will be ignored for all other value types.
* <p>
* If the {@link #locale()} is specified, the number format will be applied in the context of the given locale.
* Otherwise, the system's default locale will be used.
*
* @return A decimal format string as processable by {@link DecimalFormat}.
* @see #locale()
*/
String valueNumberFormat() default "";
/**
* Specifies the locale to be used when processing {@link SimpleDateFormat} or {@link DecimalFormat} for key or
* value mappings in maps. The locale should be a plain tag representing the language, such as "en" for English,
* "de" for German, etc.
* <p>
* If no locale is specified, the system's default locale will be used.
*
* @return A string representing the locale to be used when formatting dates or numbers in maps.
*/
String locale() default "";
/**
* A key value qualifier can be specified to aid the selection process of a suitable mapper. This is useful in
* case multiple mappers (hand written of internal) qualify and result in an 'Ambiguous mapping methods found'
* error.
*
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
* @see Qualifier
*/
Class<? extends Annotation>[] keyQualifiedBy() default { };
/**
* String-based form of qualifiers; When looking for a suitable mapping method to map this map mapping method's key
* type, MapStruct will only consider those methods carrying directly or indirectly (i.e. on the class-level) a
* {@link Named} annotation for each of the specified qualifier names.
* <p>
* Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and
* are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large
* number of qualifiers as no custom annotation types are needed.
*
* @return One or more qualifier name(s)
* @see #keyQualifiedBy()
* @see Named
*/
String[] keyQualifiedByName() default { };
/**
* A value qualifier can be specified to aid the selection process of a suitable mapper for the values in the map.
* This is useful in case multiple mappers (hand written of internal) qualify and result in an 'Ambiguous mapping
* methods found' error.
* <p>
* A qualifier is a custom annotation and can be placed on either a hand written mapper class or a method.
*
* @return the qualifiers
* @see Qualifier
*/
Class<? extends Annotation>[] valueQualifiedBy() default { };
/**
* String-based form of qualifiers; When looking for a suitable mapping method to map this map mapping method's
* value type, MapStruct will only consider those methods carrying directly or indirectly (i.e. on the class-level)
* a {@link Named} annotation for each of the specified qualifier names.
* <p>
* Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and
* are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large
* number of qualifiers as no custom annotation types are needed.
*
* @return One or more qualifier name(s)
* @see #valueQualifiedBy()
* @see Named
*/
String[] valueQualifiedByName() default { };
/**
* Specifies the type of the key to be used in the result of the mapping method in case multiple mapping
* methods qualify.
*
*
* @return the resultType to select
*/
Class<?> keyTargetType() default void.class;
/**
* Specifies the type of the value to be used in the result of the mapping method in case multiple mapping
* methods qualify.
*
*
* @return the resultType to select
*/
Class<?> valueTargetType() default void.class;
/**
* The strategy to be applied when {@code null} is passed as source value to this map mapping. If no
* strategy is configured, the strategy given via {@link MapperConfig#nullValueMappingStrategy()} or
* {@link Mapper#nullValueMappingStrategy()} will be applied, using {@link NullValueMappingStrategy#RETURN_NULL}
* by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapping.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* Allows detailed control over the key mapping process.
*
* @return the mapping control
*
* @since 1.4
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> keyMappingControl() default MappingControl.class;
/**
* Allows detailed control over the value mapping process.
*
* @return the mapping control
*
* @since 1.4
*
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> valueMappingControl() default MappingControl.class;
}

View File

@ -0,0 +1,391 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.control.MappingControl;
import org.mapstruct.factory.Mappers;
import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR;
/**
* Marks an interface or abstract class as a mapper and activates the generation of a implementation of that type via
* MapStruct.
*
* <p>
* <strong>Example 1:</strong> Creating mapper
* </p>
* <pre><code class='java'>
* &#64;Mapper
* public interface CarMapper {
* CarDto toCarDto(Car source);
* }
* </code></pre>
* <p>
* <strong>Example 2:</strong> Use additional mappers with parameters {@link #uses()}, {@link #componentModel()}
* and {@link #injectionStrategy()}
* </p>
* <pre><code class='java'>
* // we have MarkMapper (map field "mark" to field "name" to upper case)
* &#64;Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
* public class MarkMapper {
* public String mapMark(String mark) {
* return mark.toUpperCase();
* }
* }
* // we have CarMapper
* &#64;Mapper(
* componentModel = MappingConstants.ComponentModel.SPRING,
* uses = MarkMapper.class,
* injectionStrategy = InjectionStrategy.CONSTRUCTOR)
* public interface CarMapper {
* &#64;Mapping(target = "name", source = "mark")
* CarDto convertMap(CarEntity carEntity);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* &#64;Component
* public class CarMapperImpl implements CarMapper {
* private final MarkMapper markMapper;
* &#64;Autowired
* public CarMapperImpl(MarkMapper markMapper) {
* this.markMapper = markMapper;
* }
* &#64;Override
* public CarDto convertMap(CarEntity carEntity) {
* if ( carEntity == null ) {
* return null;
* }
* CarDto carDto = new CarDto();
* carDto.setName( markMapper.mapMark( carEntity.getMark() ) );
* return carDto;
* }
* }
* </code></pre>
*
* @author Gunnar Morling
* @see Javadoc
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface Mapper {
/**
* Other mapper types used by this mapper. May be hand-written classes or other mappers generated by MapStruct. No
* cycle between generated mapper classes must be created.
*
* @return The mapper types used by this mapper.
*/
Class<?>[] uses() default { };
/**
* Additional types for which an import statement is to be added to the generated mapper implementation class.
* This allows to refer to those types from within mapping expressions given via {@link Mapping#expression()},
* {@link Mapping#defaultExpression()} or using
* their simple name rather than their fully-qualified name.
*
* @return classes to add in the imports of the generated implementation.
*/
Class<?>[] imports() default { };
/**
* How unmapped properties of the source type of a mapping should be
* reported. The method overrides an unmappedSourcePolicy set in a central
* configuration set by {@link #config() }
*
* @return The reporting policy for unmapped source properties.
*
* @since 1.3
*/
ReportingPolicy unmappedSourcePolicy() default ReportingPolicy.IGNORE;
/**
* How unmapped properties of the target type of a mapping should be
* reported. The method overrides an unmappedTargetPolicy set in a central
* configuration set by {@link #config() }
*
* @return The reporting policy for unmapped target properties.
*/
ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.WARN;
/**
* How lossy (narrowing) conversion, for instance long to integer should be
* reported. The method overrides an typeConversionPolicy set in a central
* configuration set by {@link #config() }
*
* @since 1.3
*
* @return The reporting policy for unmapped target properties.
*/
ReportingPolicy typeConversionPolicy() default ReportingPolicy.IGNORE;
/**
* Specifies the component model to which the generated mapper should
* adhere. Supported values are
* <ul>
* <li> {@code default}: the mapper uses no component model, instances are
* typically retrieved via {@link Mappers#getMapper(Class)}</li>
* <li>
* {@code cdi}: the generated mapper is an application-scoped CDI bean and
* can be retrieved via {@code @Inject}</li>
* <li>
* {@code spring}: the generated mapper is a Spring bean and
* can be retrieved via {@code @Autowired}</li>
* <li>
* {@code jsr330}: the generated mapper is annotated with {@code @javax.inject.Named} and
* {@code @Singleton}, and can be retrieved via {@code @Inject}.
* The annotations will either be from javax.inject or jakarta.inject,
* depending on which one is available, with javax.inject having precedence.</li>
* <li>
* {@code jakarta}: the generated mapper is annotated with {@code @jakarta.inject.Named} and
* {@code @Singleton}, and can be retrieved via {@code @Inject}.</li>
* </ul>
* The method overrides a componentModel set in a central configuration set
* by {@link #config() }
*
* @return The component model for the generated mapper.
*/
String componentModel() default MappingConstants.ComponentModel.DEFAULT;
/**
* Specifies the name of the implementation class. The {@code <CLASS_NAME>} will be replaced by the
* interface/abstract class name.
* <p>
* Defaults to postfixing the name with {@code Impl}: {@code <CLASS_NAME>Impl}
*
* @return The implementation name.
* @see #implementationPackage()
*/
String implementationName() default "<CLASS_NAME>Impl";
/**
* Specifies the target package for the generated implementation. The {@code <PACKAGE_NAME>} will be replaced by the
* interface's or abstract class' package.
* <p>
* Defaults to using the same package as the mapper interface/abstract class
*
* @return the implementation package.
* @see #implementationName()
*/
String implementationPackage() default "<PACKAGE_NAME>";
/**
* A class annotated with {@link MapperConfig} which should be used as configuration template. Any settings given
* via {@link Mapper} will take precedence over the settings from the referenced configuration source. The list of
* referenced mappers will contain all mappers given via {@link Mapper#uses()} and {@link MapperConfig#uses()}.
*
* @return A class which should be used as configuration template.
*/
Class<?> config() default void.class;
/**
* The strategy to be applied when propagating the value of collection-typed properties. By default, only JavaBeans
* accessor methods (setters or getters) will be used, but it is also possible to invoke a corresponding adder
* method for each element of the source collection (e.g. {@code orderDto.addOrderLine()}).
* <p>
* Any setting given for this attribute will take precedence over {@link MapperConfig#collectionMappingStrategy()},
* if present.
*
* @return The strategy applied when propagating the value of collection-typed properties.
*/
CollectionMappingStrategy collectionMappingStrategy() default CollectionMappingStrategy.ACCESSOR_ONLY;
/**
* The strategy to be applied when {@code null} is passed as source argument value to the methods of this mapper.
* If no strategy is configured, the strategy given via {@link MapperConfig#nullValueMappingStrategy()} will be
* applied, using {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to the methods of this mapper.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when {@code null} is passed as source argument value to an {@link IterableMapping} of
* this mapper. If unset, the strategy set with {@link #nullValueMappingStrategy()} will be applied. If neither
* strategy is configured, the strategy given via {@link MapperConfig#nullValueIterableMappingStrategy()} will be
* applied, using {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @since 1.5
*
* @return The strategy to be applied when {@code null} is passed as source value to an {@link IterableMapping} of
* this mapper.
*/
NullValueMappingStrategy nullValueIterableMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when {@code null} is passed as source argument value to a {@link MapMapping} of this
* mapper. If unset, the strategy set with {@link #nullValueMappingStrategy()} will be applied. If neither strategy
* is configured, the strategy given via {@link MapperConfig#nullValueMapMappingStrategy()} will be applied, using
* {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @since 1.5
*
* @return The strategy to be applied when {@code null} is passed as source value to a {@link MapMapping} of this
* mapper.
*/
NullValueMappingStrategy nullValueMapMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when a source bean property is {@code null} or not present. If no strategy is
* configured, the strategy given via {@link MapperConfig#nullValuePropertyMappingStrategy()} will be applied,
* {@link NullValuePropertyMappingStrategy#SET_TO_NULL} will be used by default.
*
* @since 1.3
*
* @return The strategy to be applied when {@code null} is passed as source property value or the source property
* is not present.
*/
NullValuePropertyMappingStrategy nullValuePropertyMappingStrategy() default
NullValuePropertyMappingStrategy.SET_TO_NULL;
/**
* The strategy to use for applying method-level configuration annotations of prototype methods in the interface
* specified with {@link #config()}. Annotations that can be inherited are for example {@link Mapping},
* {@link IterableMapping}, {@link MapMapping}, or {@link BeanMapping}.
* <p>
* If no strategy is configured, the strategy given via {@link MapperConfig#mappingInheritanceStrategy()} will be
* applied, using {@link MappingInheritanceStrategy#EXPLICIT} as default.
*
* @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface
* specified with {@link #config()}.
*/
MappingInheritanceStrategy mappingInheritanceStrategy() default MappingInheritanceStrategy.EXPLICIT;
/**
* Determines when to include a null check on the source property value of a bean mapping.
*
* Can be overridden by the one on {@link MapperConfig}, {@link BeanMapping} or {@link Mapping}.
*
* @return strategy how to do null checking
*/
NullValueCheckStrategy nullValueCheckStrategy() default ON_IMPLICIT_CONVERSION;
/**
* Determines how to handle missing implementation for super classes when using the {@link SubclassMapping}.
*
* Can be overridden by the one on {@link BeanMapping}, but overrides {@link MapperConfig}.
*
* @return strategy to handle missing implementation combined with {@link SubclassMappings}.
*
* @since 1.5
*/
SubclassExhaustiveStrategy subclassExhaustiveStrategy() default COMPILE_ERROR;
/**
* Specifies the exception type to be thrown when a missing subclass implementation is detected
* in combination with {@link SubclassMappings}, based on the {@link #subclassExhaustiveStrategy()}.
* <p>
* This exception will only be thrown when the {@code subclassExhaustiveStrategy} is set to
* {@link SubclassExhaustiveStrategy#RUNTIME_EXCEPTION}.
*
* @return the exception class to throw when missing implementations are found.
* Defaults to {@link IllegalArgumentException}.
*/
Class<? extends Exception> subclassExhaustiveException() default IllegalArgumentException.class;
/**
* Determines whether to use field or constructor injection. This is only used on annotated based component models
* such as CDI, Spring and JSR 330.
*
* If no strategy is configured, {@link InjectionStrategy#FIELD} will be used as default.
*
* @return strategy how to inject
*/
InjectionStrategy injectionStrategy() default InjectionStrategy.FIELD;
/**
* If MapStruct could not find another mapping method or apply an automatic conversion it will try to generate a
* sub-mapping method between the two beans. If this property is set to {@code true} MapStruct will not try to
* automatically generate sub-mapping methods.
* <p>
* Can be configured by the {@link MapperConfig#disableSubMappingMethodsGeneration()} as well.
* <p>
* Note: If you need to use {@code disableSubMappingMethodsGeneration} please contact the MapStruct team at
* <a href="https://mapstruct.org">mapstruct.org</a> or
* <a href="https://github.com/mapstruct/mapstruct">github.com/mapstruct/mapstruct</a> to share what problem you
* are facing with the automatic sub-mapping generation.
*
* @return whether the automatic generation of sub-mapping methods is disabled
*
* @since 1.2
*/
boolean disableSubMappingMethodsGeneration() default false;
/**
* The information that should be used for the builder mappings. This can be used to define custom build methods
* for the builder strategy that one uses.
*
* If no builder is defined the builder given via {@link MapperConfig#builder()} will be applied.
*
* <p>
* NOTE: In case no builder is defined here, in {@link BeanMapping} or {@link MapperConfig} and there is a single
* build method, then that method would be used.
* <p>
* If the builder is defined and there is a single method that does not match the name of the build method then
* a compile error will occur
*
* @return the builder information
*
* @since 1.3
*/
Builder builder() default @Builder;
/**
* Allows detailed control over the mapping process.
*
* @return the mapping control
*
* @since 1.4
*
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> mappingControl() default MappingControl.class;
/**
* Exception that should be thrown by the generated code if no mapping matches for enums.
* If no exception is configured, the exception given via {@link MapperConfig#unexpectedValueMappingException()}
* will be used, using {@link IllegalArgumentException} by default.
*
* <p>
* Note:
* <ul>
* <li>
* The defined exception should at least have a constructor with a {@link String} parameter.
* </li>
* <li>
* If the defined exception is a checked exception then the enum mapping methods should have that exception
* in the throws clause.
* </li>
* </ul>
*
* @return the exception that should be used in the generated code
*
* @since 1.4
*/
Class<? extends Exception> unexpectedValueMappingException() default IllegalArgumentException.class;
/**
* Flag indicating whether the addition of a time stamp in the {@code @Generated} annotation should be suppressed.
* i.e. not be added.
*
* The method overrides the flag set in a central configuration set by {@link #config()}
* or through an annotation processor option.
*
* @return whether the addition of a timestamp should be suppressed
*
* @since 1.5
*/
boolean suppressTimestampInGenerated() default false;
}

View File

@ -0,0 +1,361 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.control.MappingControl;
import org.mapstruct.factory.Mappers;
import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
import static org.mapstruct.SubclassExhaustiveStrategy.COMPILE_ERROR;
/**
* Marks a class or interface as configuration source for generated mappers. This allows to share common configurations
* between several mapper classes.
* <p>
* Generally, any settings given via {@link Mapper} take precedence over the settings given via the referenced
* {@code MapperConfig}. The lists of referenced mappers given via {@link Mapper#uses()} and
* {@link MapperConfig#uses()} will be merged.
* <p>
* Additionally, mapper configuration classes may declare one more <em>prototype mapping methods</em>. These methods are
* not meant to be invoked themselves (no implementation will generated for mapper config classes), but serve as
* configuration template for mapping methods declared by actual mapper classes. Depending on the configured
* {@link #mappingInheritanceStrategy()}, the configuration can be inherited either explicitly using
* {@link InheritConfiguration} or {@link InheritInverseConfiguration}, or automatically in case all source and target
* types are assignable.
* </p>
*
* <p>
* <strong>Example:</strong>
* </p>
* <pre><code class='java'>
* // create config
* &#64;MapperConfig(
* uses = CustomMapperViaMapperConfig.class,
* unmappedTargetPolicy = ReportingPolicy.ERROR
* )
* public interface CentralConfig {
* }
* </code></pre>
* <pre><code class='java'>
* // use config
* &#64;Mapper(config = CentralConfig.class, uses = { CustomMapperViaMapper.class } )
* public interface SourceTargetMapper {
* // ...
* }
* </code></pre>
* <pre><code class='java'>
* // result after applying CentralConfig
* &#64;Mapper(
* uses = { CustomMapperViaMapper.class, CustomMapperViaMapperConfig.class },
* unmappedTargetPolicy = ReportingPolicy.ERROR
* )
* public interface SourceTargetMapper {
* // ...
* }
* </code></pre>
*
* @author Sjaak Derksen
* @see Mapper#config()
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface MapperConfig {
/**
* The mapper types used by this mapper.
*
* @return The mapper types used by this mapper.
*/
Class<?>[] uses() default { };
/**
* Additional types for which an import statement is to be added to the generated mapper implementation class.
* This allows to refer to those types from within mapping expressions given via {@link Mapping#expression()},
* {@link Mapping#defaultExpression()} or using
* their simple name rather than their fully-qualified name.
*
* @return classes to add in the imports of the generated implementation.
*
* @since 1.4
*/
Class<?>[] imports() default { };
/**
* How unmapped properties of the source type of a mapping should be
* reported.
*
* @return The reporting policy for unmapped source properties.
*
* @since 1.3
*/
ReportingPolicy unmappedSourcePolicy() default ReportingPolicy.IGNORE;
/**
* How unmapped properties of the target type of a mapping should be
* reported.
*
* @return The reporting policy for unmapped target properties.
*/
ReportingPolicy unmappedTargetPolicy() default ReportingPolicy.WARN;
/**
* How lossy (narrowing) conversion, for instance: long to integer should be
* reported.
*
* @since 1.3
*
* @return The reporting policy for type conversion.
*/
ReportingPolicy typeConversionPolicy() default ReportingPolicy.IGNORE;
/**
* Specifies the component model to which the generated mapper should
* adhere. Supported values are
* <ul>
* <li> {@code default}: the mapper uses no component model, instances are
* typically retrieved via {@link Mappers#getMapper(Class)}</li>
* <li>
* {@code cdi}: the generated mapper is an application-scoped CDI bean and
* can be retrieved via {@code @Inject}</li>
* <li>
* {@code spring}: the generated mapper is a Spring bean and
* can be retrieved via {@code @Autowired}</li>
* <li>
* {@code jsr330}: the generated mapper is annotated with {@code @javax.inject.Named} and
* {@code @Singleton}, and can be retrieved via {@code @Inject}.
* The annotations will either be from javax.inject or jakarta.inject,
* depending on which one is available, with javax.inject having precedence.</li>
* <li>
* {@code jakarta}: the generated mapper is annotated with {@code @jakarta.inject.Named} and
* {@code @Singleton}, and can be retrieved via {@code @Inject}.</li>
* </ul>
*
* @return The component model for the generated mapper.
*/
String componentModel() default MappingConstants.ComponentModel.DEFAULT;
/**
* Specifies the name of the implementation class. The {@code <CLASS_NAME>} will be replaced by the
* interface/abstract class name.
* <p>
* Defaults to postfixing the name with {@code Impl}: {@code <CLASS_NAME>Impl}
*
* @return The implementation name.
* @see #implementationPackage()
*/
String implementationName() default "<CLASS_NAME>Impl";
/**
* Specifies the target package for the generated implementation. The {@code <PACKAGE_NAME>} will be replaced by the
* interface's or abstract class' package.
* <p>
* Defaults to using the same package as the mapper interface/abstract class
*
* @return the implementation package.
* @see #implementationName()
*/
String implementationPackage() default "<PACKAGE_NAME>";
/**
* The strategy to be applied when propagating the value of collection-typed properties. By default, only JavaBeans
* accessor methods (setters or getters) will be used, but it is also possible to invoke a corresponding adder
* method for each element of the source collection (e.g. {@code orderDto.addOrderLine()}).
*
* @return The strategy applied when propagating the value of collection-typed properties.
*/
CollectionMappingStrategy collectionMappingStrategy() default CollectionMappingStrategy.ACCESSOR_ONLY;
/**
* The strategy to be applied when {@code null} is passed as source argument value to mapping methods. If no
* strategy is configured, {@link NullValueMappingStrategy#RETURN_NULL} will be used by default.
*
* @return The strategy to be applied when {@code null} is passed as source value to mapping methods.
*/
NullValueMappingStrategy nullValueMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when {@code null} is passed as source argument value to an {@link IterableMapping}.
* If no strategy is configured, the strategy given via {@link #nullValueMappingStrategy()} will be applied, using
* {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @since 1.5
*
* @return The strategy to be applied when {@code null} is passed as source value to an {@link IterableMapping}.
*/
NullValueMappingStrategy nullValueIterableMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when {@code null} is passed as source argument value to a {@link MapMapping}.
* If no strategy is configured, the strategy given via {@link #nullValueMappingStrategy()} will be applied, using
* {@link NullValueMappingStrategy#RETURN_NULL} by default.
*
* @since 1.5
*
* @return The strategy to be applied when {@code null} is passed as source value to a {@link MapMapping}.
*/
NullValueMappingStrategy nullValueMapMappingStrategy() default NullValueMappingStrategy.RETURN_NULL;
/**
* The strategy to be applied when a source bean property is {@code null} or not present. If no strategy is
* configured, {@link NullValuePropertyMappingStrategy#SET_TO_NULL} will be used by default.
*
* @since 1.3
*
* @return The strategy to be applied when {@code null} is passed as source property value or the source property
* is not present.
*/
NullValuePropertyMappingStrategy nullValuePropertyMappingStrategy() default
NullValuePropertyMappingStrategy.SET_TO_NULL;
/**
* The strategy to use for applying method-level configuration annotations of prototype methods in the interface
* annotated with this annotation. Annotations that can be inherited are for example {@link Mapping},
* {@link IterableMapping}, {@link MapMapping}, or {@link BeanMapping}.
* <p>
* If no strategy is configured, {@link MappingInheritanceStrategy#EXPLICIT} will be used as default.
*
* @return The strategy to use for applying {@code @Mapping} configurations of prototype methods in the interface
* annotated with this annotation.
*/
MappingInheritanceStrategy mappingInheritanceStrategy()
default MappingInheritanceStrategy.EXPLICIT;
/**
* Determines when to include a null check on the source property value of a bean mapping.
*
* Can be overridden by the one on {@link Mapper}, {@link BeanMapping} or {@link Mapping}.
*
* @return strategy how to do null checking
*/
NullValueCheckStrategy nullValueCheckStrategy() default ON_IMPLICIT_CONVERSION;
/**
* Determines how to handle missing implementation for super classes when using the {@link SubclassMapping}.
*
* Can be overridden by the one on {@link BeanMapping} or {@link Mapper}.
*
* @return strategy to handle missing implementation combined with {@link SubclassMappings}.
*
* @since 1.5
*/
SubclassExhaustiveStrategy subclassExhaustiveStrategy() default COMPILE_ERROR;
/**
* Specifies the exception type to be thrown when a missing subclass implementation is detected
* in combination with {@link SubclassMappings}, based on the {@link #subclassExhaustiveStrategy()}.
* <p>
* This exception will only be thrown when the {@code subclassExhaustiveStrategy} is set to
* {@link SubclassExhaustiveStrategy#RUNTIME_EXCEPTION}.
*
* @return the exception class to throw when missing implementations are found.
* Defaults to {@link IllegalArgumentException}.
*/
Class<? extends Exception> subclassExhaustiveException() default IllegalArgumentException.class;
/**
* Determines whether to use field or constructor injection. This is only used on annotated based component models
* such as CDI, Spring and JSR 330.
*
* Can be overridden by the one on {@link Mapper}.
*
* If no strategy is configured, {@link InjectionStrategy#FIELD} will be used as default.
*
* @return strategy how to inject
*/
InjectionStrategy injectionStrategy() default InjectionStrategy.FIELD;
/**
* If MapStruct could not find another mapping method or apply an automatic conversion it will try to generate a
* sub-mapping method between the two beans. If this property is set to {@code true} MapStruct will not try to
* automatically generate sub-mapping methods.
* <p>
* Can be overridden by {@link Mapper#disableSubMappingMethodsGeneration()}
* <p>
* Note: If you need to use {@code disableSubMappingMethodsGeneration} please contact the MapStruct team at
* <a href="https://mapstruct.org">mapstruct.org</a> or
* <a href="https://github.com/mapstruct/mapstruct">github.com/mapstruct/mapstruct</a> to share what problem you
* are facing with the automatic sub-mapping generation.
*
* @return whether the automatic generation of sub-mapping methods is disabled
*
* @since 1.2
*/
boolean disableSubMappingMethodsGeneration() default false;
/**
* The information that should be used for the builder mappings. This can be used to define custom build methods
* for the builder strategy that one uses.
*
* <p>
* Can be overridden by {@link MapperConfig#builder()}.
*
* <p>
* NOTE: In case no builder is defined here, in {@link BeanMapping} or {@link Mapper} and there is a single
* build method, then that method would be used.
* <p>
* If the builder is defined and there is a single method that does not match the name of the build method then
* a compile error will occur
*
* @return the builder information
*
* @since 1.3
*/
Builder builder() default @Builder;
/**
* Allows detailed control over the mapping process.
*
* @return the mapping control
*
* @since 1.4
*
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> mappingControl() default MappingControl.class;
/**
* Exception that should be thrown by the generated code if no mapping matches for enums.
* If no exception is configured, {@link IllegalArgumentException} will be used by default.
*
* <p>
* Note:
* <ul>
* <li>
* The defined exception should at least have a constructor with a {@link String} parameter.
* </li>
* <li>
* If the defined exception is a checked exception then the enum mapping methods should have that exception
* in the throws clause.
* </li>
* </ul>
*
* @return the exception that should be used in the generated code
*
* @since 1.4
*/
Class<? extends Exception> unexpectedValueMappingException() default IllegalArgumentException.class;
/**
* Flag indicating whether the addition of a time stamp in the {@code @Generated} annotation should be suppressed.
* i.e. not be added.
*
* The method overrides the flag set through an annotation processor option.
*
* @return whether the addition of a timestamp should be suppressed
*
* @since 1.5
*/
boolean suppressTimestampInGenerated() default false;
}

View File

@ -1,45 +1,147 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.mapstruct.control.MappingControl;
import static org.mapstruct.NullValueCheckStrategy.ON_IMPLICIT_CONVERSION;
/**
* Configures the mapping of one bean attribute or enum constant.
* Configures the mapping of one bean attribute.
* <p>
* The name of the mapped attribute or constant is to be specified via {@link #target()}. For mapped bean attributes it
* is assumed by default that the attribute has the same name in the source bean. Alternatively, one of
* {@link #source()}, {@link #expression()} or {@link #constant()} can be specified to define the property source.
* </p>
* <p>
* In addition, the attributes {@link #dateFormat()} and {@link #qualifiedBy()} may be used to further define the
* mapping.
* </p>
*
* <p>
* <strong>Example 1:</strong> Implicitly mapping fields with the same name:
* </p>
* <pre><code class='java'>
* // Both classes HumanDto and Human have property with name "fullName"
* // properties with the same name will be mapped implicitly
* &#64;Mapper
* public interface HumanMapper {
* HumanDto toHumanDto(Human human)
* }
* </code></pre>
* <pre><code class='java'>
* // generates:
* &#64;Override
* public HumanDto toHumanDto(Human human) {
* humanDto.setFullName( human.getFullName() );
* // ...
* }
* </code></pre>
*
* <p><strong>Example 2:</strong> Mapping properties with different names</p>
* <pre><code class='java'>
* // We need map Human.companyName to HumanDto.company
* // we can use &#64;Mapping with parameters {@link #source()} and {@link #target()}
* &#64;Mapper
* public interface HumanMapper {
* &#64;Mapping(source="companyName", target="company")
* HumanDto toHumanDto(Human human)
* }
* </code></pre>
* <pre><code class='java'>
* // generates:
* &#64;Override
* public HumanDto toHumanDto(Human human) {
* humanDto.setCompany( human.getCompanyName() );
* // ...
* }
* </code></pre>
* <p>
* <strong>Example 3:</strong> Mapping with expression
* <b>IMPORTANT NOTE:</b> Now it works only for Java
* </p>
* <pre><code class='java'>
* // We need map Human.name to HumanDto.countNameSymbols.
* // we can use {@link #expression()} for it
* &#64;Mapper
* public interface HumanMapper {
* &#64;Mapping(target="countNameSymbols", expression="java(human.getName().length())")
* HumanDto toHumanDto(Human human)
* }
* </code></pre>
* <pre><code class='java'>
* // generates:
*&#64;Override
* public HumanDto toHumanDto(Human human) {
* humanDto.setCountNameSymbols( human.getName().length() );
* //...
* }
* </code></pre>
* <p>
* <strong>Example 4:</strong> Mapping to constant
* </p>
* <pre><code class='java'>
* // We need map HumanDto.name to string constant "Unknown"
* // we can use {@link #constant()} for it
* &#64;Mapper
* public interface HumanMapper {
* &#64;Mapping(target="name", constant="Unknown")
* HumanDto toHumanDto(Human human)
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* &#64;Override
* public HumanDto toHumanDto(Human human) {
* humanDto.setName( "Unknown" );
* // ...
* }
* </code></pre>
* <p>
* <strong>Example 5:</strong> Mapping with default value
* </p>
* <pre><code class='java'>
* // We need map Human.name to HumanDto.fullName, but if Human.name == null, then set value "Somebody"
* // we can use {@link #defaultValue()} or {@link #defaultExpression()} for it
* &#64;Mapper
* public interface HumanMapper {
* &#64;Mapping(source="name", target="name", defaultValue="Somebody")
* HumanDto toHumanDto(Human human)
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* &#64;Override
* public HumanDto toHumanDto(Human human) {
* if ( human.getName() != null ) {
* humanDto.setFullName( human.getName() );
* }
* else {
* humanDto.setFullName( "Somebody" );
* }
* // ...
* }
* </code></pre>
*
* @author Gunnar Morling
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
@Repeatable(Mappings.class)
@Retention(RetentionPolicy.CLASS)
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
public @interface Mapping {
/**
@ -64,7 +166,7 @@ public @interface Mapping {
* <li>When no matching property is found, MapStruct looks for a matching parameter name instead.</li>
* <li>When used to map an enum constant, the name of the constant member is to be given.</li>
* </ol>
* Either this attribute or {@link #constant()} or {@link #expression()} may be specified for a given mapping.
* This attribute can not be used together with {@link #constant()} or {@link #expression()}.
*
* @return The source name of the configured property or enum constant.
*/
@ -73,39 +175,140 @@ public @interface Mapping {
/**
* A format string as processable by {@link SimpleDateFormat} if the attribute is mapped from {@code String} to
* {@link Date} or vice-versa. Will be ignored for all other attribute types and when mapping enum constants.
* <p>
* If the {@link #locale()} is also specified, the format will consider the specified locale when processing
* the date. Otherwise, the system's default locale will be used.
*
* @return A date format string as processable by {@link SimpleDateFormat}.
* @see #locale()
*/
String dateFormat() default "";
/**
* A constant {@link String} based on which the specified target property is to be set. If the designated target
* property is not of type {@code String}, the value will be converted by applying a matching conversion method or
* built-in conversion.
* A format string as processable by {@link DecimalFormat} if the annotated method maps from a
* {@link Number} to a {@link String} or vice-versa. Will be ignored for all other element types.
* <p>
* Either this attribute or {@link #source()} or {@link #expression()} may be specified for a given mapping.
* If the {@link #locale()} is also specified, the number format will be applied in the context of the given locale.
* Otherwise, the system's default locale will be used to process the number format.
*
* @return A decimal format string as processable by {@link DecimalFormat}.
* @see #locale()
*/
String numberFormat() default "";
/**
* Specifies the locale to be used when processing {@link #dateFormat()} or {@link #numberFormat()}.
* <p>
* The locale should be a plain tag representing the language, such as "en" for English, "de" for German, etc.
* <p>
* If no locale is specified, the system's default locale will be used.
*
* @return A string representing the locale to be used when formatting dates or numbers.
*/
String locale() default "";
/**
* A constant {@link String} based on which the specified target property is to be set.
* <p>
* When the designated target property is of type:
* </p>
* <ol>
* <li>primitive or boxed (e.g. {@code java.lang.Long}).
* <p>
* MapStruct checks whether the primitive can be assigned as valid literal to the primitive or boxed type.
* </p>
* <ul>
* <li>
* If possible, MapStruct assigns as literal.
* </li>
* <li>
* If not possible, MapStruct will try to apply a user defined mapping method.
* </li>
* </ul>
* </li>
* <li>other
* <p>
* MapStruct handles the constant as {@code String}. The value will be converted by applying a matching method,
* type conversion method or built-in conversion.
* <p>
* </li>
* </ol>
* <p>
* You can use {@link #qualifiedBy()} or {@link #qualifiedByName()} to force the use of a conversion method
* even when one would not apply. (e.g. {@code String} to {@code String})
* </p>
* <p>
* This attribute can not be used together with {@link #source()}, {@link #defaultValue()},
* {@link #defaultExpression()} or {@link #expression()}.
*
* @return A constant {@code String} constant specifying the value for the designated target property
*/
String constant() default "";
/**
* An expression {@link String} based on which the specified target property is to be set. The format is determined
* by a type of expression. For instance:
* {@code expression = "java(new org.example.TimeAndFormat( s.getTime(), s.getFormat() ))")} will insert the java
* expression in the designated {@link #target()} property.
* An expression {@link String} based on which the specified target property is to be set.
* <p>
* Either this attribute or {@link #source()} or {@link #constant()} may be specified for a given mapping.
* Currently, Java is the only supported "expression language" and expressions must be given in form of Java
* expressions using the following format: {@code java(<EXPRESSION>)}. For instance the mapping:
* <pre><code>
* &#64;Mapping(
* target = "someProp",
* expression = "java(new TimeAndFormat( s.getTime(), s.getFormat() ))"
* )
* </code></pre>
* <p>
* will cause the following target property assignment to be generated:
* <p>
* {@code targetBean.setSomeProp( new TimeAndFormat( s.getTime(), s.getFormat() ) )}.
* <p>
* Any types referenced in expressions must be given via their fully-qualified name. Alternatively, types can be
* imported via {@link Mapper#imports()}.
* <p>
* This attribute can not be used together with {@link #source()}, {@link #defaultValue()},
* {@link #defaultExpression()}, {@link #qualifiedBy()}, {@link #qualifiedByName()} or {@link #constant()}.
*
* @return A constant {@code String} constant specifying the value for the designated target property
* @return An expression specifying the value for the designated target property
*/
String expression() default "";
/**
* A defaultExpression {@link String} based on which the specified target property is to be set
* if and only if the specified source property is null.
* <p>
* Currently, Java is the only supported "expression language" and expressions must be given in form of Java
* expressions using the following format: {@code java(<EXPRESSION>)}. For instance the mapping:
* <pre><code>
* &#64;Mapping(
* target = "someProp",
* defaultExpression = "java(new TimeAndFormat( s.getTime(), s.getFormat() ))"
* )
* </code></pre>
* <p>
* will cause the following target property assignment to be generated:
* <p>
* {@code targetBean.setSomeProp( new TimeAndFormat( s.getTime(), s.getFormat() ) )}.
* <p>
* Any types referenced in expressions must be given via their fully-qualified name. Alternatively, types can be
* imported via {@link Mapper#imports()}.
* <p>
* This attribute can not be used together with {@link #expression()}, {@link #defaultValue()}
* or {@link #constant()}.
*
* @return An expression specifying a defaultValue for the designated target property if the designated source
* property is null
*
* @since 1.3
*/
String defaultExpression() default "";
/**
* Whether the property specified via {@link #target()} should be ignored by the generated mapping method or not.
* This can be useful when certain attributes should not be propagated from source or target or when properties in
* This can be useful when certain attributes should not be propagated from source to target or when properties in
* the target object are populated using a decorator and thus would be reported as unmapped target property by
* default.
* <p>
* If you have multiple properties to ignore,
* you can use the {@link Ignored} annotation instead and group them all at once.
*
* @return {@code true} if the given property should be ignored, {@code false} otherwise
*/
@ -115,8 +318,189 @@ public @interface Mapping {
* A qualifier can be specified to aid the selection process of a suitable mapper. This is useful in case multiple
* mapping methods (hand written or generated) qualify and thus would result in an 'Ambiguous mapping methods found'
* error. A qualifier is a custom annotation and can be placed on a hand written mapper class or a method.
* <p>
* Note that {@link #defaultValue()} usage will also be converted using this qualifier.
*
* @return the qualifiers
* @see Qualifier
*/
Class<? extends Annotation>[] qualifiedBy() default { };
/**
* String-based form of qualifiers; When looking for a suitable mapping method for a given property, MapStruct will
* only consider those methods carrying directly or indirectly (i.e. on the class-level) a {@link Named} annotation
* for each of the specified qualifier names.
* <p>
* Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and
* are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large
* number of qualifiers as no custom annotation types are needed.
* <p>
* Note that {@link #defaultValue()} usage will also be converted using this qualifier.
*
* @return One or more qualifier name(s)
* @see #qualifiedBy()
* @see Named
*/
String[] qualifiedByName() default { };
/**
* A qualifier can be specified to aid the selection process of a suitable presence check method.
* This is useful in case multiple presence check methods qualify and thus would result in an
* 'Ambiguous presence check methods found' error.
* A qualifier is a custom annotation and can be placed on a hand written mapper class or a method.
* This is similar to the {@link #qualifiedBy()}, but it is only applied for {@link Condition} methods.
*
* @return the qualifiers
* @see Qualifier
* @see #qualifiedBy()
* @since 1.5
*/
Class<? extends Annotation>[] conditionQualifiedBy() default { };
/**
* String-based form of qualifiers for condition / presence check methods;
* When looking for a suitable presence check method for a given property, MapStruct will
* only consider those methods carrying directly or indirectly (i.e. on the class-level) a {@link Named} annotation
* for each of the specified qualifier names.
*
* This is similar like {@link #qualifiedByName()} but it is only applied for {@link Condition} methods.
* <p>
* Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and
* are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large
* number of qualifiers as no custom annotation types are needed.
* </p>
*
*
* @return One or more qualifier name(s)
* @see #conditionQualifiedBy()
* @see #qualifiedByName()
* @see Named
* @since 1.5
*/
String[] conditionQualifiedByName() default { };
/**
* A conditionExpression {@link String} based on which the specified property is to be checked
* whether it is present or not.
* <p>
* Currently, Java is the only supported "expression language" and expressions must be given in form of Java
* expressions using the following format: {@code java(<EXPRESSION>)}. For instance the mapping:
* <pre><code>
* &#64;Mapping(
* target = "someProp",
* conditionExpression = "java(s.getAge() &#60; 18)"
* )
* </code></pre>
* <p>
* will cause the following target property assignment to be generated:
* <pre><code>
* if (s.getAge() &#60; 18) {
* targetBean.setSomeProp( s.getSomeProp() );
* }
* </code></pre>
* <p>
* Any types referenced in expressions must be given via their fully-qualified name. Alternatively, types can be
* imported via {@link Mapper#imports()}.
* <p>
* This attribute can not be used together with {@link #expression()} or {@link #constant()}.
*
* @return An expression specifying a condition check for the designated property
*
* @since 1.5
*/
String conditionExpression() default "";
/**
* Specifies the result type of the mapping method to be used in case multiple mapping methods qualify.
*
* @return the resultType to select
*/
Class<?> resultType() default void.class;
/**
* One or more properties of the result type on which the mapped property depends. The generated method
* implementation will invoke the setters of the result type ordered so that the given dependency relationship(s)
* are satisfied. Useful in case one property setter depends on the state of another property of the result type.
* <p>
* An error will be raised in case a cycle in the dependency relationships is detected.
*
* @return the dependencies of the mapped property
*/
String[] dependsOn() default { };
/**
* In case the source property is {@code null}, the provided default {@link String} value is set.
* <p>
* When the designated target property is of type:
* </p>
* <ol>
* <li>primitive or boxed (e.g. {@code java.lang.Long}).
* <p>
* MapStruct checks whether the primitive can be assigned as valid literal to the primitive or boxed type.
* </p>
* <ul>
* <li>
* If possible, MapStruct assigns as literal.
* </li>
* <li>
* If not possible, MapStruct will try to apply a user defined mapping method.
* </li>
* </ul>
* <p>
* </li>
* <li>other
* <p>
* MapStruct handles the constant as {@code String}. The value will be converted by applying a matching method,
* type conversion method or built-in conversion.
* <p>
* </li>
* </ol>
* <p>
* This attribute can not be used together with {@link #constant()}, {@link #expression()}
* or {@link #defaultExpression()}.
*
* @return Default value to set in case the source property is {@code null}.
*/
String defaultValue() default "";
/**
* Determines when to include a null check on the source property value of a bean mapping.
*
* Can be overridden by the one on {@link MapperConfig}, {@link Mapper} or {@link BeanMapping}.
*
* @since 1.3
*
* @return strategy how to do null checking
*/
NullValueCheckStrategy nullValueCheckStrategy() default ON_IMPLICIT_CONVERSION;
/**
* The strategy to be applied when the source property is {@code null} or not present. If no strategy is configured,
* the strategy given via {@link MapperConfig#nullValuePropertyMappingStrategy()},
* {@link BeanMapping#nullValuePropertyMappingStrategy()} or
* {@link Mapper#nullValuePropertyMappingStrategy()} will be applied.
*
* {@link NullValuePropertyMappingStrategy#SET_TO_NULL} will be used by default.
*
* @since 1.3
*
* @return The strategy to be applied when {@code null} is passed as source property value or the source property
* is not present.
*/
NullValuePropertyMappingStrategy nullValuePropertyMappingStrategy()
default NullValuePropertyMappingStrategy.SET_TO_NULL;
/**
* Allows detailed control over the mapping process.
*
* @return the mapping control
*
* @since 1.4
*
* @see org.mapstruct.control.DeepClone
* @see org.mapstruct.control.NoComplexMapping
* @see org.mapstruct.control.MappingControl
*/
Class<? extends Annotation> mappingControl() default MappingControl.class;
}

View File

@ -0,0 +1,154 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Contains all constants defined in the mapping process.
*
* @author Sjaak Derksen
*/
public final class MappingConstants {
private MappingConstants() {
}
/**
* In an {@link ValueMapping} this represents a {@code null} source or target.
*/
public static final String NULL = "<NULL>";
/**
* In an {@link ValueMapping} this represents any source that is not already mapped by either a defined mapping or
* by means of name based mapping.
*
* NOTE: The value is only applicable to {@link ValueMapping#source()} and not to {@link ValueMapping#target()}.
*/
public static final String ANY_REMAINING = "<ANY_REMAINING>";
/**
* In an {@link ValueMapping} this represents any source that is not already mapped by a defined mapping.
*
* NOTE: The value is only applicable to {@link ValueMapping#source()} and not to {@link ValueMapping#target()}.
*
*/
public static final String ANY_UNMAPPED = "<ANY_UNMAPPED>";
/**
* In an {@link ValueMapping} this represents any target that will be mapped to an
* {@link java.lang.IllegalArgumentException} which will be thrown at runtime.
* <p>
* NOTE: The value is only applicable to {@link ValueMapping#target()} and not to {@link ValueMapping#source()}.
*/
public static final String THROW_EXCEPTION = "<THROW_EXCEPTION>";
/**
* In an {@link EnumMapping} this represent the enum transformation strategy that adds a suffix to the source enum.
*
* @since 1.4
*/
public static final String SUFFIX_TRANSFORMATION = "suffix";
/**
* In an {@link EnumMapping} this represent the enum transformation strategy that strips a suffix from the source
* enum.
*
* @since 1.4
*/
public static final String STRIP_SUFFIX_TRANSFORMATION = "stripSuffix";
/**
* In an {@link EnumMapping} this represent the enum transformation strategy that adds a prefix to the source enum.
*
* @since 1.4
*/
public static final String PREFIX_TRANSFORMATION = "prefix";
/**
* In an {@link EnumMapping} this represent the enum transformation strategy that strips a prefix from the source
* enum.
*
* @since 1.4
*/
public static final String STRIP_PREFIX_TRANSFORMATION = "stripPrefix";
/**
* In an {@link EnumMapping} this represent the enum transformation strategy that applies case transformation
* at the source.
*
* @since 1.5
*/
public static final String CASE_TRANSFORMATION = "case";
/**
* Specifies the component model constants to which the generated mapper should adhere.
* It can be used with the annotation {@link Mapper#componentModel()} or {@link MapperConfig#componentModel()}
*
* <p>
* <strong>Example:</strong>
* </p>
* <pre><code class='java'>
* // Spring component model
* &#64;Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
* </code></pre>
*
* @since 1.5.0
*/
public static final class ComponentModel {
private ComponentModel() {
}
/**
* The mapper uses no component model, instances are typically retrieved
* via {@link org.mapstruct.factory.Mappers#getMapper(java.lang.Class)}
*
*/
public static final String DEFAULT = "default";
/**
* The generated mapper is an application-scoped CDI bean and can be retrieved via @Inject.
* The annotations are either from {@code javax} or {@code jakarta}.
* Priority have the {@code javax} annotations.
* In case you want to only use Jakarta then use {@link #JAKARTA_CDI}.
*
* @see #JAKARTA_CDI
*/
public static final String CDI = "cdi";
/**
* The generated mapper is a Spring bean and can be retrieved via @Autowired
*
*/
public static final String SPRING = "spring";
/**
* The generated mapper is annotated with @Named and @Singleton, and can be retrieved via @Inject.
* The annotations are either from {@code javax.inject} or {@code jakarta.inject}.
* Priority have the {@code javax.inject} annotations.
* In case you want to only use Jakarta then use {@link #JAKARTA}.
*
* @see #JAKARTA
*/
public static final String JSR330 = "jsr330";
/**
* The generated mapper is annotated with @Named and @Singleton, and can be retrieved via @Inject.
* The annotations are from {@code jakarta.inject}.
* In case you want to use {@code javax.inject} then use {@link #JSR330}.
*
* @see #JSR330
*/
public static final String JAKARTA = "jakarta";
/**
* The generated mapper is an application-scoped Jakarta CDI bean and can be retrieved via @Inject.
* @see #CDI
*/
public static final String JAKARTA_CDI = "jakarta-cdi";
}
}

View File

@ -0,0 +1,38 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for inheriting configurations given for methods of prototype mapping methods (declared on mapper config
* classes) to actual mapping methods declared on mappers referring to such config class via {@link Mapper#config()}.
*
* @author Andreas Gudian
*/
public enum MappingInheritanceStrategy {
/**
* Apply the method-level configuration annotations only if the prototype method is explicitly referenced using
* {@link InheritConfiguration}.
*/
EXPLICIT,
/**
* Inherit the method-level forward configuration annotations automatically if source and target types of the
* prototype method are assignable from the types of a given mapping method.
*/
AUTO_INHERIT_FROM_CONFIG,
/**
* Inherit the method-level reverse configuration annotations automatically if source and target types of the
* prototype method are assignable from the target and source types of a given mapping method.
*/
AUTO_INHERIT_REVERSE_FROM_CONFIG,
/**
* Inherit the method-level forward and reverse configuration annotations automatically if source and target types
* of the prototype method are assignable from the types of a given mapping method.
*/
AUTO_INHERIT_ALL_FROM_CONFIG;
}

View File

@ -0,0 +1,62 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares a parameter of a mapping method to be the target of the mapping.
* <p>
* Not more than one parameter can be declared as {@code MappingTarget}.
* <p>
* <b>NOTE:</b> The parameter passed as a mapping target <b>must</b> not be {@code null}.
*
* <p>
* <strong>Example 1:</strong> Update exist bean without return value
* </p>
* <pre><code class='java'>
* &#64;Mapper
* public interface HumanMapper {
* void updateHuman(HumanDto humanDto, @MappingTarget Human human);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* &#64;Override
* public void updateHuman(HumanDto humanDto, Human human) {
* human.setName( humanDto.getName() );
* // ...
* }
* </code></pre>
* <p>
* <strong>Example 2:</strong> Update exist bean and return it
* </p>
* <pre><code class='java'>
* &#64;Mapper
* public interface HumanMapper {
* Human updateHuman(HumanDto humanDto, @MappingTarget Human human);
* }
* </code></pre>
* // generates:
* <pre><code class='java'>
* &#64;Override
* public Human updateHuman(HumanDto humanDto, Human human) {
* // ...
* human.setName( humanDto.getName() );
* return human;
* }
*</code></pre>
*
*
* @author Andreas Gudian
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface MappingTarget {
}

View File

@ -1,20 +1,7 @@
/**
* Copyright 2012-2014 Gunnar Morling (http://www.gunnarmorling.de/)
* and/or other contributors as indicated by the @authors tag. See the
* copyright.txt file in the distribution for a full listing of all
* contributors.
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
@ -25,11 +12,37 @@ import java.lang.annotation.Target;
/**
* Configures the mappings of several bean attributes.
* <p>
* <strong>TIP: When using Java 8 or later, you can omit the @Mappings
* wrapper annotation and directly specify several @Mapping annotations on one method.</strong>
*
* <p>These two examples are equal.
* </p>
* <pre><code class='java'>
* // before Java 8
* &#64;Mapper
* public interface MyMapper {
* &#64;Mappings({
* &#64;Mapping(target = "firstProperty", source = "first"),
* &#64;Mapping(target = "secondProperty", source = "second")
* })
* HumanDto toHumanDto(Human human);
* }
* </code></pre>
* <pre><code class='java'>
* // Java 8 and later
* &#64;Mapper
* public interface MyMapper {
* &#64;Mapping(target = "firstProperty", source = "first"),
* &#64;Mapping(target = "secondProperty", source = "second")
* HumanDto toHumanDto(Human human);
* }
* </code></pre>
*
* @author Gunnar Morling
*/
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE })
public @interface Mappings {
/**

View File

@ -0,0 +1,90 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Marks mapping methods with the given qualifier name. Can be used to qualify a single method or all methods of a given
* type by specifying this annotation on the type level.
* <p>
* Will be used to select the correct mapping methods when mapping a bean property type, element of an iterable type
* or the key/value of a map type.
* <p>
* Example (both methods of {@code Titles} are capable to convert a string, but the ambiguity is resolved by applying
* the qualifiers in {@code @Mapping}:
*
* <pre>
* <code>
* &#64;Named("TitleTranslator")
* public class Titles {
*
* &#64;Named("EnglishToGerman")
* public String translateTitleEG(String title) {
* // some mapping logic
* }
*
* &#64;Named("GermanToEnglish")
* public String translateTitleGE(String title) {
* // some mapping logic
* }
* }
*
* &#64;Mapper( uses = Titles.class )
* public interface MovieMapper {
*
* &#64;Mapping( target = "title", qualifiedByName = { "TitleTranslator", "EnglishToGerman" } )
* GermanRelease toGerman( OriginalRelease movies );
*
* }
* </code>
* </pre>
*
* The following implementation of {@code MovieMapper} will be generated:
*
* <pre>
* <code>
*
* public class MovieMapperImpl implements MovieMapper {
* private final Titles titles = new Titles();
*
* &#64;Override
* public GermanRelease toGerman(OriginalRelease movies) {
* if ( movies == null ) {
* return null;
* }
*
* GermanRelease germanRelease = new GermanRelease();
*
* germanRelease.setTitle( titles.translateTitleEG( movies.getTitle() ) );
*
* return germanRelease;
* }
* }
* </code>
* </pre>
*
* @author Sjaak Derksen
* @see org.mapstruct.Mapping#qualifiedByName()
* @see IterableMapping#qualifiedByName()
* @see MapMapping#keyQualifiedByName()
* @see MapMapping#valueQualifiedByName()
*/
@Target( { ElementType.TYPE, ElementType.METHOD } )
@Retention( RetentionPolicy.CLASS )
@Qualifier
public @interface Named {
/**
* A name qualifying the annotated element
*
* @return the name.
*/
String value();
}

View File

@ -0,0 +1,15 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* To be used as a default value for enum class annotation elements.
*
* @author Ben Zegveld
* @since 1.6
*/
enum NullEnum {
}

View File

@ -0,0 +1,43 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for dealing with null source values.
*
* <b>Note:</b> This strategy is not in effect when a specific source presence check method is defined
* in the service provider interface (SPI).
* <p>
* <b>Note</b>: some types of mappings (collections, maps), in which MapStruct is instructed to use a getter or adder
* as target accessor see {@link CollectionMappingStrategy}, MapStruct will always generate a source property null
* check, regardless the value of the {@link NullValueCheckStrategy} to avoid addition of {@code null} to the target
* collection or map.
*
* @author Sean Huang
*/
public enum NullValueCheckStrategy {
/**
* This option includes a null check. When:
* <br>
* <br>
* <ol>
* <li>a source value is directly assigned to a target</li>
* <li>a source value assigned to a target by calling a type conversion on the target first</li>
* </ol>
* <br>
* <b>NOTE:</b> mapping methods (generated or hand written) are excluded from this null check. They are intended to
* handle a null source value as 'valid' input.
*
*/
ON_IMPLICIT_CONVERSION,
/**
* This option always includes a null check.
*/
ALWAYS;
}

View File

@ -0,0 +1,34 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for dealing with {@code null} values passed to mapping methods.
*
* @author Sjaak Derksen
*/
public enum NullValueMappingStrategy {
/**
* If {@code null} is passed to a mapping method, {@code null} will be returned. That's the default behavior if no
* alternative strategy is configured globally, for given mapper or method.
*/
RETURN_NULL,
/**
* If {@code null} is passed to a mapping method, a default value will be returned. The value depends on the kind of
* the annotated method:
* <ul>
* <li>For bean mapping methods the target type will be instantiated and returned. Any properties of the target type
* which are mapped via {@link Mapping#expression()} or {@link Mapping#constant()} will be populated based on the
* given expression or constant. Note that expressions must be prepared to deal with {@code null} values in this
* case.</li>
* <li>For iterable mapping methods an empty collection will be returned.</li>
* <li>For map mapping methods an empty map will be returned.</li>
* </ul>
*/
RETURN_DEFAULT;
}

View File

@ -0,0 +1,57 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for dealing with {@code null} or not present properties in the source bean. The
* {@link NullValuePropertyMappingStrategy} can be defined on {@link MapperConfig}, {@link Mapper}, {@link BeanMapping}
* and {@link Mapping}.
* Precedence is arranged in the reverse order. So {@link Mapping} will override {@link BeanMapping}, will
* override {@link Mapper}
*
* The enum <b>only applies to update methods</b>: methods that update a pre-existing target (annotated with
* {@code @}{@link MappingTarget}).
*
* <p>
* <b>Note</b>: some types of mappings (collections, maps), in which MapStruct is instructed to use a getter or adder
* as target accessor see {@link CollectionMappingStrategy}, MapStruct will always generate a source property
* null check, regardless the value of the {@link NullValuePropertyMappingStrategy} to avoid addition of {@code null}
* to the target collection or map. Since the target is assumed to be initialised this strategy will not be applied.
*
* @author Sjaak Derksen
* @since 1.3
*/
public enum NullValuePropertyMappingStrategy {
/**
* If a source bean property equals {@code null} the target bean property will be set explicitly to {@code null}.
*/
SET_TO_NULL,
/**
* If a source bean property equals {@code null} the target bean property will be set to its default value.
* <p>
* This means:
* <ol>
* <li>For {@code List} MapStruct generates an {@code ArrayList}</li>
* <li>For {@code Map} a {@code HashMap}</li>
* <li>For arrays an empty array</li>
* <li>For {@code String} {@code ""}</li>
* <li>for primitive / boxed types a representation of {@code 0} or {@code false}</li>
* <li>For all other objects an new instance is created, requiring an empty constructor.</li>
* </ol>
* <p>
* Make sure that a {@link Mapping#defaultValue()} is defined if no empty constructor is available on
* the default value.
*/
SET_TO_DEFAULT,
/**
* If a source bean property equals {@code null} the target bean property will be ignored and retain its
* existing value.
*/
IGNORE;
}

View File

@ -0,0 +1,60 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation marks a method as a <em>factory method</em> to create beans.
* <p>
* By default beans are created during the mapping process with the default constructor. If a factory method with a
* return type that is assignable to the required object type is present, then the factory method is used instead.
* <p>
* Factory methods can be defined without parameters, with an {@code @}{@link TargetType} parameter, a
* {@code @}{@link Context} parameter, or with the mapping source parameter. If any of those parameters are defined,
* then the mapping method that is supposed to use the factory method needs to be declared with an assignable result
* type, assignable context parameter, and/or assignable source types.
* <p>
* <strong>Note:</strong> the usage of this annotation is <em>optional</em> when used in the {@link Mapper#uses()}
* if no source parameters are part of the signature, i.e. it is declared without parameters or only with
* {@code @}{@link TargetType} and/or {@code @}{@link Context}. It is however <em>mandatory</em> when used inside
* an {@code @}{@link Context} annotated class.
* <p>
* <strong>Example:</strong> Using a factory method for entities to check whether the entity already exists in the
* EntityManager and then returns the managed instance:
*
* <pre>
* <code>
* &#64;ApplicationScoped // CDI component model
* public class ReferenceMapper {
*
* &#64;PersistenceContext
* private EntityManager em;
*
* &#64;ObjectFactory
* public &lt;T extends AbstractEntity&gt; T resolve(AbstractDto sourceDto, &#64;TargetType Class&lt;T&gt; type) {
* T entity = em.find( type, sourceDto.getId() );
* return entity != null ? entity : type.newInstance();
* }
* }
* </code>
* </pre>
* <p>
* If there are two factory methods, both serving the same type, one with no parameters and one taking sources as input,
* then the one with the source parameters is favored. If there are multiple such factories, an ambiguity error is
* shown.
*
* @author Remo Meier
* @since 1.2
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.METHOD)
public @interface ObjectFactory {
}

View File

@ -0,0 +1,90 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares an annotation type to be a qualifier. Qualifier annotations allow unambiguously identify a suitable mapping
* method in case several methods qualify to map a bean property, iterable element etc.
* <p>
* Can be used in:
* <ul>
* <li>{@link Mapping#qualifiedBy() }</li>
* <li>{@link BeanMapping#qualifiedBy() }</li>
* <li>{@link IterableMapping#qualifiedBy() }</li>
* <li>{@link MapMapping#keyQualifiedBy() }</li>
* <li>{@link MapMapping#valueQualifiedBy() }</li>
* <li>{@link SubclassMapping#qualifiedBy() }</li>
* </ul>
* <p><strong>Example:</strong></p>
* <pre><code class='java'>
* // create qualifiers
* &#64;Qualifier
* &#64;Target(ElementType.TYPE)
* &#64;Retention(RetentionPolicy.CLASS)
* public &#64;interface TitleTranslator {}
*
* &#64;Qualifier
* &#64;Target(ElementType.METHOD)
* &#64;Retention(RetentionPolicy.CLASS)
* public @interface EnglishToGerman {}
*
* &#64;Qualifier
* &#64;Target(ElementType.METHOD)
* &#64;Retention(RetentionPolicy.CLASS)
* public @interface GermanToEnglish {}
* </code></pre>
* <pre><code class='java'>
* // we can create class with map methods
* &#64;TitleTranslator
* public class Titles {
* &#64;EnglishToGerman
* public String translateTitleEnglishToGerman(String title) {
* // some mapping logic
* }
* &#64;GermanToEnglish
* public String translateTitleGermanToEnglish(String title) {
* // some mapping logic
* }
* }
* </code></pre>
* <pre><code class='java'>
* // usage
* &#64;Mapper( uses = Titles.class )
* public interface MovieMapper {
* &#64;Mapping( target = "title", qualifiedBy = { TitleTranslator.class, EnglishToGerman.class } )
* GermanRelease toGerman( OriginalRelease movies );
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class MovieMapperImpl implements MovieMapper {
* private final Titles titles = new Titles();
* &#64;Override
* public GermanRelease toGerman(OriginalRelease movies) {
* if ( movies == null ) {
* return null;
* }
* GermanRelease germanRelease = new GermanRelease();
* germanRelease.setTitle( titles.translateTitleEnglishToGerman( movies.getTitle() ) );
* return germanRelease;
* }
* }
* </code></pre>
*
* <b>NOTE:</b> Qualifiers should have {@link RetentionPolicy#CLASS}.
*
* @author Sjaak Derksen
* @see Named
*/
@Target(ElementType.ANNOTATION_TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface Qualifier {
}

View File

@ -0,0 +1,33 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import javax.tools.Diagnostic.Kind;
/**
* Policy for reporting issues occurring during the generation of a mapper
* implementation.
*
* @author Gunnar Morling
*/
public enum ReportingPolicy {
/**
* No report will be created for the given issue.
*/
IGNORE,
/**
* A report with {@link Kind#WARNING} will be created for the given issue.
*/
WARN,
/**
* A report with {@link Kind#ERROR} will be created for the given issue,
* causing the compilation to fail.
*/
ERROR;
}

View File

@ -0,0 +1,74 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation marks a method as a <em>check method</em> to check if a source parameter needs to be mapped.
* <p>
* By default, source parameters are checked against {@code null}, unless they are primitives.
* <p>
* Check methods have to return {@code boolean}.
* The following parameters are accepted for the presence check methods:
* <ul>
* <li>The mapping source parameter</li>
* <li>{@code @}{@link Context} parameter</li>
* </ul>
*
* <strong>Note:</strong> The usage of this annotation is <em>mandatory</em>
* for a method to be considered as a source check method.
*
* <pre><code class='java'>
* public class PresenceCheckUtils {
*
* &#64;SourceParameterCondition
* public static boolean isDefined(Car car) {
* return car != null &#38;&#38; car.getId() != null;
* }
* }
*
* &#64;Mapper(uses = PresenceCheckUtils.class)
* public interface CarMapper {
*
* CarDto map(Car car);
* }
* </code></pre>
*
* The following implementation of {@code CarMapper} will be generated:
*
* <pre><code class='java'>
* public class CarMapperImpl implements CarMapper {
*
* &#64;Override
* public CarDto map(Car car) {
* if ( !PresenceCheckUtils.isDefined( car ) ) {
* return null;
* }
*
* CarDto carDto = new CarDto();
*
* carDto.setId( car.getId() );
* // ...
*
* return carDto;
* }
* }
* </code></pre>
*
* @author Filip Hrisafov
* @since 1.6
* @see Condition @Condition
*/
@Target({ ElementType.METHOD })
@Retention(RetentionPolicy.CLASS)
@Condition(appliesTo = ConditionStrategy.SOURCE_PARAMETERS)
public @interface SourceParameterCondition {
}

View File

@ -0,0 +1,26 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation marks a <em>presence check method</em> parameter as a source property name parameter.
* <p>
* This parameter enables conditional filtering based on source property name at run-time.
* Parameter must be of type {@link String} and can be present only in {@link Condition} method.
* </p>
*
* @author Oliver Erhart
* @since 1.6
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface SourcePropertyName {
}

View File

@ -0,0 +1,28 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
/**
* Strategy for dealing with subclassMapping annotated methods.
*
* @since 1.5
* @author Ben Zegveld
*/
public enum SubclassExhaustiveStrategy {
/**
* If there is no valid constructor or known method to create the return value of a with `@SubclassMapping`
* annotated mapping then a compilation error will be thrown.
*/
COMPILE_ERROR,
/**
* If there is no valid constructor or known method to create the return value of a with `@SubclassMapping`
* annotated mapping then an {@link IllegalArgumentException} will be thrown if a call is made with a type for which
* there is no {@link SubclassMapping} available.
*/
RUNTIME_EXCEPTION;
}

View File

@ -0,0 +1,110 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.util.Experimental;
/**
* Configures the mapping to handle hierarchy of the source type.
* <p>
* The subclass to be mapped is to be specified via {@link #source()}.
* The subclass to map to is to be specified via {@link #target()}.
* </p>
* <p>
* This annotation can be combined with &#64;Mapping annotations.
* </p>
*
* <pre><code class='java'>
* &#64;Mapper
* public interface MyMapper {
* &#64;SubclassMapping (target = TargetSubclass.class, source = SourceSubclass.class)
* TargetParent mapParent(SourceParent parent);
*
* TargetSubclass mapSubclass(SourceSubclass subInstant);
* }
* </code></pre>
* Below follow examples of the implementation for the mapParent method.
* <strong>Example 1:</strong> For parents that cannot be created. (e.g. abstract classes or interfaces)
* <pre><code class='java'>
* // generates
* &#64;Override
* public TargetParent mapParent(SourceParent parent) {
* if (parent instanceof SourceSubclass) {
* return mapSubclass( (SourceSubclass) parent );
* }
* else {
* throw new IllegalArgumentException("Not all subclasses are supported for this mapping. Missing for "
* + parent.getClass());
* }
* }
* </code></pre>
* <strong>Example 2:</strong> For parents that can be created. (e.g. normal classes or interfaces with
* &#64;Mapper( uses = ObjectFactory.class ) )
* <pre><code class='java'>
* // generates
* &#64;Override
* public TargetParent mapParent(SourceParent parent) {
* TargetParent targetParent1;
* if (parent instanceof SourceSubclass) {
* targetParent1 = mapSubclass( (SourceSubclass) parent );
* }
* else {
* targetParent1 = new TargetParent();
* // ...
* }
* }
* </code></pre>
*
* @author Ben Zegveld
* @since 1.5
*/
@Repeatable(value = SubclassMappings.class)
@Retention(RetentionPolicy.CLASS)
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Experimental
public @interface SubclassMapping {
/**
* @return the source subclass to check for before using the default mapping as fallback.
*/
Class<?> source();
/**
* @return the target subclass to map the source to.
*/
Class<?> target();
/**
* A qualifier can be specified to aid the selection process of a suitable mapper. This is useful in case multiple
* mapping methods (hand written or generated) qualify and thus would result in an 'Ambiguous mapping methods found'
* error. A qualifier is a custom annotation and can be placed on a hand written mapper class or a method.
*
* @return the qualifiers
* @see Qualifier
*/
Class<? extends Annotation>[] qualifiedBy() default {};
/**
* String-based form of qualifiers; When looking for a suitable mapping method for a given property, MapStruct will
* only consider those methods carrying directly or indirectly (i.e. on the class-level) a {@link Named} annotation
* for each of the specified qualifier names.
* <p>
* Note that annotation-based qualifiers are generally preferable as they allow more easily to find references and
* are safe for refactorings, but name-based qualifiers can be a less verbose alternative when requiring a large
* number of qualifiers as no custom annotation types are needed.
*
* @return One or more qualifier name(s)
* @see #qualifiedBy()
* @see Named
*/
String[] qualifiedByName() default {};
}

View File

@ -0,0 +1,58 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.mapstruct.util.Experimental;
/**
* Configures the SubclassMappings of several subclasses.
* <p>
* <strong>TIP: When using java 8 or later, you can omit the @SubclassMappings
* Wrapper annotation and directly specify several @SubclassMapping annotations
* on one method.</strong>
* </p>
* <p>These two examples are equal.
* </p>
* <pre><code class='java'>
* // before java 8
* &#64;Mapper
* public interface MyMapper {
* &#64;SubclassMappings({
* &#64;SubclassMapping(source = FirstSub.class, target = FirstTargetSub.class),
* &#64;SubclassMapping(source = SecondSub.class, target = SecondTargetSub.class)
* })
* ParentTarget toParentTarget(Parent parent);
* }
* </code></pre>
* <pre><code class='java'>
* // java 8 and later
* &#64;Mapper
* public interface MyMapper {
* &#64;SubclassMapping(source = First.class, target = FirstTargetSub.class),
* &#64;SubclassMapping(source = SecondSub.class, target = SecondTargetSub.class)
* ParentTarget toParentTarget(Parent parent);
* }
* </code></pre>
*
* @author Ben Zegveld
* @since 1.5
*/
@Target({ ElementType.METHOD, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.CLASS)
@Experimental
public @interface SubclassMappings {
/**
* @return the subclassMappings to apply.
*/
SubclassMapping[] value();
}

View File

@ -0,0 +1,25 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation marks a <em>presence check method</em> parameter as a target property name parameter.
* <p>
* This parameter enables conditional filtering based on target property name at run-time.
* Parameter must be of type {@link String} and can be present only in {@link Condition} method.
* </p>
* @author Nikola Ivačič
* @since 1.6
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface TargetPropertyName {
}

View File

@ -0,0 +1,53 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Declares a parameter of a custom mapping method to be populated with the target type of the mapping.
* <p>
* Not more than one parameter can be declared as {@code TargetType} and that parameter needs to be of type
* {@link Class} (may be parameterized), or a super-type of it.
*
* <p>
* <strong>Example:</strong>
* </p>
* <pre><code class='java'>
* public class EntityFactory {
* public &lt;T extends BaseEntity&gt; T createEntity(@TargetType Class&lt;T&gt; entityClass) {
* return // ... custom factory logic
* }
* }
* &#64;Mapper(uses = EntityFactory.class)
* public interface CarMapper {
* CarEntity carDtoToCar(CarDto dto);
* }
* </code></pre>
* <pre><code class='java'>
* // generates
* public class CarMapperImpl implements CarMapper {
* private final EntityFactory entityFactory = new EntityFactory();
* &#64;Override
* public CarEntity carDtoToCar(CarDto dto) {
* if ( dto == null ) {
* return null;
* }
* CarEntity carEntity = entityFactory.createEntity( CarEntity.class );
* return carEntity;
* }
* }
* </code></pre>
*
* @author Andreas Gudian
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.CLASS)
public @interface TargetType {
}

View File

@ -0,0 +1,124 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Configures the mapping of source constant value to target constant value.
* <p>
* Supported mappings are
* <ol>
* <li>Enumeration to Enumeration</li>
* </ol>
* <b>Example 1:</b>
*
* <pre><code>
* public enum OrderType { RETAIL, B2B, C2C, EXTRA, STANDARD, NORMAL }
*
* public enum ExternalOrderType { RETAIL, B2B, SPECIAL, DEFAULT }
*
* &#64;ValueMapping(target = "SPECIAL", source = "EXTRA"),
* &#64;ValueMapping(target = "DEFAULT", source = "STANDARD"),
* &#64;ValueMapping(target = "DEFAULT", source = "NORMAL")
* ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
* </code>
* Mapping result:
* +---------------------+----------------------------+
* | OrderType | ExternalOrderType |
* +---------------------+----------------------------+
* | null | null |
* | OrderType.EXTRA | ExternalOrderType.SPECIAL |
* | OrderType.STANDARD | ExternalOrderType.DEFAULT |
* | OrderType.NORMAL | ExternalOrderType.DEFAULT |
* | OrderType.RETAIL | ExternalOrderType.RETAIL |
* | OrderType.B2B | ExternalOrderType.B2B |
* +---------------------+----------------------------+
* </pre>
*
* <b>Example 2:</b>
*
* <pre><code>
* &#64;ValueMapping( source = MappingConstants.NULL, target = "DEFAULT" ),
* &#64;ValueMapping( source = "STANDARD", target = MappingConstants.NULL ),
* &#64;ValueMapping( source = MappingConstants.ANY_REMAINING, target = "SPECIAL" )
* ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
* </code>
* Mapping result:
* +---------------------+----------------------------+
* | OrderType | ExternalOrderType |
* +---------------------+----------------------------+
* | null | ExternalOrderType.DEFAULT |
* | OrderType.STANDARD | null |
* | OrderType.RETAIL | ExternalOrderType.RETAIL |
* | OrderType.B2B | ExternalOrderType.B2B |
* | OrderType.NORMAL | ExternalOrderType.SPECIAL |
* | OrderType.EXTRA | ExternalOrderType.SPECIAL |
* +---------------------+----------------------------+
* </pre>
*
* <b>Example 3:</b>
*
* MapStruct will <B>WARN</B> on incomplete mappings. However, if for some reason no match is found, an
* {@link java.lang.IllegalStateException} will be thrown. This compile-time error can be avoided by
* using {@link MappingConstants#THROW_EXCEPTION} for {@link ValueMapping#target()}. It will result an
* {@link java.lang.IllegalArgumentException} at runtime.
* <pre><code>
* &#64;ValueMapping( source = "STANDARD", target = "DEFAULT" ),
* &#64;ValueMapping( source = "C2C", target = MappingConstants.THROW_EXCEPTION )
* ExternalOrderType orderTypeToExternalOrderType(OrderType orderType);
* </code>
* Mapping result:
* {@link java.lang.IllegalArgumentException} with the error message:
* Unexpected enum constant: C2C
* </pre>
*
* @author Sjaak Derksen
*/
@Repeatable(ValueMappings.class)
@Retention(RetentionPolicy.CLASS)
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
public @interface ValueMapping {
/**
* The source value constant to use for this mapping.
*
* <p>
* <b>Valid values:</b>
* <ol>
* <li>enum constant name</li>
* <li>{@link MappingConstants#NULL}</li>
* <li>{@link MappingConstants#ANY_REMAINING}</li>
* <li>{@link MappingConstants#ANY_UNMAPPED}</li>
* </ol>
* <p>
* <b>NOTE:</b>When using &lt;ANY_REMAINING&gt;, MapStruct will perform the normal name based mapping, in which
* source is mapped to target based on enum identifier equality. Using &lt;ANY_UNMAPPED&gt; will not apply name
* based mapping.
*
* @return The source value.
*/
String source();
/**
* The target value constant to use for this mapping.
*
* <p>
* <b>Valid values:</b>
* <ol>
* <li>enum constant name</li>
* <li>{@link MappingConstants#NULL}</li>
* <li>{@link MappingConstants#THROW_EXCEPTION}</li>
* </ol>
*
* @return The target value.
*/
String target();
}

View File

@ -0,0 +1,49 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Constructs a set of value (constant) mappings.
* <p>
* <strong>TIP: When using Java 8 or later, you can omit the @ValueMappings
* wrapper annotation and directly specify several @ValueMapping annotations on one method.</strong>
*
* <p>These two examples are equal</p>
* <pre><code class='java'>
* // before Java 8
* &#64;Mapper
* public interface GenderMapper {
* &#64;ValueMappings({
* &#64;ValueMapping(target = "M", source = "MALE"),
* &#64;ValueMapping(target = "F", source = "FEMALE")
* })
* GenderDto mapToDto(Gender gender);
* }
* </code></pre>
* <pre><code class='java'>
* //Java 8 and later
* &#64;Mapper
* public interface GenderMapper {
* &#64;ValueMapping(target = "M", source = "MALE"),
* &#64;ValueMapping(target = "F", source = "FEMALE")
* GenderDto mapToDto(Gender gender);
* }
* </code></pre>
*
* @author Sjaak Derksen
*/
@Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.CLASS)
public @interface ValueMappings {
ValueMapping[] value();
}

View File

@ -0,0 +1,24 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.control;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.mapstruct.util.Experimental;
/**
* Clones a source type to a target type (assuming source and target are of the same type).
*
* @author Sjaak Derksen
*
* @since 1.4
*/
@Retention(RetentionPolicy.CLASS)
@Experimental
@MappingControl( MappingControl.Use.MAPPING_METHOD )
public @interface DeepClone {
}

View File

@ -0,0 +1,152 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.control;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Controls which means of mapping are considered between the source and the target in mappings.
*
* <p>
* There are several applications of <code>MappingControl</code> conceivable. One application, "deep cloning" is
* explained below in the example.
* </p>
*
* <p>
* Another application is controlling so called "complex mappings", which are not always desirable and sometimes lead to
* unexpected behaviour and prolonged compilation time.
* </p>
*
* <p><strong>Example:</strong>Cloning of an object</p>
* <p>
* When all methods are allowed, MapStruct would make a shallow copy. It would take the <code>ShelveDTO</code> in
* the <code>FridgeDTO</code> and directly enter that as target on the target <code>FridgeDTO</code>. By disabling all
* other kinds of mappings apart from {@link MappingControl.Use#MAPPING_METHOD}, see {@link DeepClone} MapStruct is
* forced to generate mapping methods all through the object graph `FridgeDTO` and hence create a deep clone.
* </p>
* <pre><code class='java'>
* public class FridgeDTO {
*
* private ShelveDTO shelve;
*
* public ShelveDTO getShelve() {
* return shelve;
* }
*
* public void setShelve(ShelveDTO shelve) {
* this.shelve = shelve;
* }
* }
* </code></pre>
* <pre><code class='java'>
* public class ShelveDTO {
*
* private CoolBeerDTO coolBeer;
*
* public CoolBeerDTO getCoolBeer() {
* return coolBeer;
* }
*
* public void setCoolBeer(CoolBeerDTO coolBeer) {
* this.coolBeer = coolBeer;
* }
* }
* </code></pre>
* <pre><code class='java'>
* public class CoolBeerDTO {
*
* private String beerCount;
*
* public String getBeerCount() {
* return beerCount;
* }
*
* public void setBeerCount(String beerCount) {
* this.beerCount = beerCount;
* }
* }
* </code></pre>
*
* <pre><code class='java'>
* &#64;Mapper(mappingControl = DeepClone.class)
* public interface CloningMapper {
*
* CloningMapper INSTANCE = Mappers.getMapper( CloningMapper.class );
*
* FridgeDTO clone(FridgeDTO in);
*
* }
* </code></pre>
*
* @author Sjaak Derksen
*
* @since 1.4
*/
@Retention(RetentionPolicy.CLASS)
@Repeatable(MappingControls.class)
@Target( ElementType.ANNOTATION_TYPE )
@MappingControl( MappingControl.Use.DIRECT )
@MappingControl( MappingControl.Use.BUILT_IN_CONVERSION )
@MappingControl( MappingControl.Use.MAPPING_METHOD )
@MappingControl( MappingControl.Use.COMPLEX_MAPPING )
public @interface MappingControl {
Use value();
enum Use {
/**
* Controls the mapping, allows for type conversion from source type to target type
* <p>
* Type conversions are typically supported directly in Java. The "toString()" is such an example,
* which allows for mapping for instance a {@link java.lang.Number} type to a {@link java.lang.String}.
* <p>
* Please refer to the MapStruct guide for more info.
*
* @since 1.4
*/
BUILT_IN_CONVERSION,
/**
* Controls the mapping from source to target type, allows mapping by calling:
* <ol>
* <li>A type conversion, passed into a mapping method</li>
* <li>A mapping method, passed into a type conversion</li>
* <li>A mapping method passed into another mapping method</li>
* </ol>
*
* @since 1.4
*/
COMPLEX_MAPPING,
/**
* Controls the mapping, allows for a direct mapping from source type to target type.
* <p>
* This means if source type and target type are of the same type, MapStruct will not perform
* any mappings anymore and assign the target to the source direct.
* <p>
* An exception are types from the package {@code java}, which will be mapped always directly.
*
* @since 1.4
*/
DIRECT,
/**
* Controls the mapping, allows for Direct Mapping from source type to target type.
* <p>
* The mapping method can be either a custom referred mapping method, or a MapStruct built in
* mapping method.
*
* @since 1.4
*/
MAPPING_METHOD
}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.control;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Allows multiple {@link MappingControl} on a class declaration.
*
* @author Sjaak Derksen
*
* @since 1.4
*/
@Retention(RetentionPolicy.CLASS)
@Target(ElementType.ANNOTATION_TYPE)
public @interface MappingControls {
MappingControl[] value();
}

View File

@ -0,0 +1,29 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.control;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.mapstruct.util.Experimental;
/**
* Disables complex mappings, mappings that require 2 mapping means (method, built-in conversion) to constitute
* a mapping from source to target.
*
* @see MappingControl.Use#COMPLEX_MAPPING
*
* @author Sjaak Derksen
*
* @since 1.4
*/
@Retention(RetentionPolicy.CLASS)
@Experimental
@MappingControl( MappingControl.Use.DIRECT )
@MappingControl( MappingControl.Use.BUILT_IN_CONVERSION )
@MappingControl( MappingControl.Use.MAPPING_METHOD )
public @interface NoComplexMapping {
}

View File

@ -0,0 +1,168 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.factory;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.ServiceLoader;
import org.mapstruct.Mapper;
/**
* Factory for obtaining mapper instances if no explicit component model such as CDI is configured via
* {@link Mapper#componentModel()}.
* <p>
* Mapper implementation types are expected to have the same fully qualified name as their interface type, with the
* suffix {@code Impl} appended. When using this factory, mapper types - and any mappers they use - are instantiated by
* invoking their public no-args constructor.
* <p>
* By convention, a single instance of each mapper is retrieved from the factory and exposed on the mapper interface
* type by declaring a member named {@code INSTANCE} like this:
*
* <pre>
* &#064;Mapper
* public interface CustomerMapper {
*
* CustomerMapper INSTANCE = Mappers.getMapper( CustomerMapper.class );
*
* // mapping methods...
* }
* </pre>
*
* @author Gunnar Morling
*/
public class Mappers {
private static final String IMPLEMENTATION_SUFFIX = "Impl";
private Mappers() {
}
/**
* Returns an instance of the given mapper type.
*
* @param clazz The type of the mapper to return.
* @param <T> The type of the mapper to create.
*
* @return An instance of the given mapper type.
*/
public static <T> T getMapper(Class<T> clazz) {
try {
List<ClassLoader> classLoaders = collectClassLoaders( clazz.getClassLoader() );
return getMapper( clazz, classLoaders );
}
catch ( ClassNotFoundException | NoSuchMethodException e ) {
throw new RuntimeException( e );
}
}
private static <T> T getMapper(Class<T> mapperType, Iterable<ClassLoader> classLoaders)
throws ClassNotFoundException, NoSuchMethodException {
for ( ClassLoader classLoader : classLoaders ) {
T mapper = doGetMapper( mapperType, classLoader );
if ( mapper != null ) {
return mapper;
}
}
throw new ClassNotFoundException("Cannot find implementation for " + mapperType.getName() );
}
private static <T> T doGetMapper(Class<T> clazz, ClassLoader classLoader) throws NoSuchMethodException {
try {
@SuppressWarnings( "unchecked" )
Class<T> implementation = (Class<T>) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX );
Constructor<T> constructor = implementation.getDeclaredConstructor();
constructor.setAccessible( true );
return constructor.newInstance();
}
catch (ClassNotFoundException e) {
return getMapperFromServiceLoader( clazz, classLoader );
}
catch ( InstantiationException | InvocationTargetException | IllegalAccessException e) {
throw new RuntimeException( e );
}
}
/**
* Returns the class of the implementation for the given mapper type.
*
* @param clazz The type of the mapper to return.
* @param <T> The type of the mapper to create.
*
* @return A class of the implementation for the given mapper type.
*
* @since 1.3
*/
public static <T> Class<? extends T> getMapperClass(Class<T> clazz) {
try {
List<ClassLoader> classLoaders = collectClassLoaders( clazz.getClassLoader() );
return getMapperClass( clazz, classLoaders );
}
catch ( ClassNotFoundException e ) {
throw new RuntimeException( e );
}
}
private static <T> Class<? extends T> getMapperClass(Class<T> mapperType, Iterable<ClassLoader> classLoaders)
throws ClassNotFoundException {
for ( ClassLoader classLoader : classLoaders ) {
Class<? extends T> mapperClass = doGetMapperClass( mapperType, classLoader );
if ( mapperClass != null ) {
return mapperClass;
}
}
throw new ClassNotFoundException( "Cannot find implementation for " + mapperType.getName() );
}
@SuppressWarnings("unchecked")
private static <T> Class<? extends T> doGetMapperClass(Class<T> clazz, ClassLoader classLoader) {
try {
return (Class<? extends T>) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX );
}
catch ( ClassNotFoundException e ) {
T mapper = getMapperFromServiceLoader( clazz, classLoader );
if ( mapper != null ) {
return (Class<? extends T>) mapper.getClass();
}
return null;
}
}
private static <T> T getMapperFromServiceLoader(Class<T> clazz, ClassLoader classLoader) {
ServiceLoader<T> loader = ServiceLoader.load( clazz, classLoader );
for ( T mapper : loader ) {
if ( mapper != null ) {
return mapper;
}
}
return null;
}
private static List<ClassLoader> collectClassLoaders(ClassLoader classLoader) {
List<ClassLoader> classLoaders = new ArrayList<>( 3 );
classLoaders.add( classLoader );
if ( Thread.currentThread().getContextClassLoader() != null ) {
classLoaders.add( Thread.currentThread().getContextClassLoader() );
}
classLoaders.add( Mappers.class.getClassLoader() );
return classLoaders;
}
}

View File

@ -0,0 +1,13 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
/**
* <p>
* Provides the {@link org.mapstruct.factory.Mappers} factory class for the retrieval of mapper instances if no
* explicit component model such as CDI is configured via {@link org.mapstruct.Mapper#componentModel()}.
* </p>
*
*/
package org.mapstruct.factory;

View File

@ -0,0 +1,18 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
/**
* <p>
* MapStruct is a code generator which simplifies the implementation of mappings between Java bean types by generating
* mapping code at compile time, following a convention-over-configuration approach. The generated code uses plain
* method invocations and thus is fast and type-safe.
* </p>
* <p>
* This package contains several annotations which allow to configure how mapper interfaces are generated.
* </p>
*
* @see <a href="https://mapstruct.org/">MapStruct reference documentation</a>
*/
package org.mapstruct;

View File

@ -0,0 +1,21 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.util;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Features that are marked with this annotation are considered <em>experimental</em>.
*
* @author Andreas Gudian
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
public @interface Experimental {
String value() default "";
}

View File

@ -0,0 +1,61 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.factory;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.mapstruct.test.model.Foo;
import org.mapstruct.test.model.SomeClass;
/**
* Unit test for {@link Mappers}.
*
* @author Gunnar Morling
*/
public class MappersTest {
@Test
public void shouldReturnImplementationInstance() {
Foo mapper = Mappers.getMapper( Foo.class );
assertThat( mapper ).isNotNull();
}
@Test
public void shouldReturnImplementationClass() {
Class<? extends Foo> mapperClass = Mappers.getMapperClass( Foo.class );
assertThat( mapperClass ).isNotNull();
assertThat( mapperClass ).isNotExactlyInstanceOf( Foo.class );
}
/**
* Checks if an implementation of a nested mapper can be found. This is a special case since
* it is named
*/
@Test
public void findsNestedMapperImpl() {
assertThat( Mappers.getMapper( SomeClass.Foo.class ) ).isNotNull();
assertThat( Mappers.getMapper( SomeClass.NestedClass.Foo.class ) ).isNotNull();
}
@Test
public void findsNestedMapperImplClass() {
assertThat( Mappers.getMapperClass( SomeClass.Foo.class ) ).isNotNull();
assertThat( Mappers.getMapperClass( SomeClass.NestedClass.Foo.class ) ).isNotNull();
}
@Test
public void shouldReturnPackagePrivateImplementationInstance() {
assertThat( Mappers.getMapper( PackagePrivateMapper.class ) ).isNotNull();
}
@Test
public void shouldReturnPackagePrivateImplementationClass() {
assertThat( Mappers.getMapperClass( PackagePrivateMapper.class ) ).isNotNull();
}
}

View File

@ -0,0 +1,10 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.factory;
interface PackagePrivateMapper {
}

View File

@ -0,0 +1,9 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.factory;
class PackagePrivateMapperImpl implements PackagePrivateMapper {
}

View File

@ -0,0 +1,10 @@
/*
* Copyright MapStruct Authors.
*
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package org.mapstruct.test.model;
public interface Foo {
}

Some files were not shown because too many files have changed in this diff Show More