-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map to collection of targets #46
Comments
marcus-talbot42
added a commit
that referenced
this issue
Sep 20, 2022
- Implemented Equalizer, which implements a type check, which allows BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map) to only map compatible collections. - Implemented BeanMapper#map(Collection, Collection), which maps a source collection, to a target collection, if both the elements of the source and target implement Equalizer and use the same class for their ID. - Implemented BeanMapper#map(Map, Map), which maps a source map, to a target map, if both the values of the source and target implement Equalizer and use the same class for their key/ID. - Both methods also map elements to the target that do not have a counterpart, simply mapping those elements to the target class. - Updated CHANGELOG.md
marcus-talbot42
added a commit
that referenced
this issue
Sep 20, 2022
- Implemented Equalizer, which implements a type check, which allows BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map) to only map compatible collections. - Implemented BeanMapper#map(Collection, Collection), which maps a source collection, to a target collection, if both the elements of the source and target implement Equalizer and use the same class for their ID. - Implemented BeanMapper#map(Map, Map), which maps a source map, to a target map, if both the values of the source and target implement Equalizer and use the same class for their key/ID. - Both methods also map elements to the target that do not have a counterpart, simply mapping those elements to the target class. - Updated CHANGELOG.md - Added tests
marcus-talbot42
added a commit
that referenced
this issue
Sep 20, 2022
- Implemented Equalizer, which implements a type check, which allows BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map) to only map compatible collections. - Implemented BeanMapper#map(Collection, Collection), which maps a source collection, to a target collection, if both the elements of the source and target implement Equalizer and use the same class for their ID. - Implemented BeanMapper#map(Map, Map), which maps a source map, to a target map, if both the values of the source and target implement Equalizer and use the same class for their key/ID. - Both methods also map elements to the target that do not have a counterpart, simply mapping those elements to the target class. - Updated CHANGELOG.md - Added tests - Made the decision whether to patch or patch&insert a configurable option.
marcus-talbot42
added a commit
that referenced
this issue
Sep 21, 2022
- Implemented Equalizer, which implements a type check, which allows BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map) to only map compatible collections. - Implemented BeanMapper#map(Collection, Collection), which maps a source collection, to a target collection, if both the elements of the source and target implement Equalizer and use the same class for their ID. - Implemented BeanMapper#map(Map, Map), which maps a source map, to a target map, if both the values of the source and target implement Equalizer and use the same class for their key/ID. - Both methods also map elements to the target that do not have a counterpart, simply mapping those elements to the target class. - Updated CHANGELOG.md - Added tests - Made the decision whether to patch or patch&insert a configurable option. By default, set to only patch.
marcus-talbot42
added a commit
that referenced
this issue
Sep 21, 2022
- Implemented Equalizer, which implements a type check, which allows BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map) to only map compatible collections. - Implemented BeanMapper#map(Collection, Collection), which maps a source collection, to a target collection, if both the elements of the source and target implement Equalizer and use the same class for their ID. - Implemented BeanMapper#map(Map, Map), which maps a source map, to a target map, if both the values of the source and target implement Equalizer and use the same class for their key/ID. - Both methods also map elements to the target that do not have a counterpart, simply mapping those elements to the target class. - Updated CHANGELOG.md - Added tests - Made the decision whether to patch or patch&insert a configurable option. By default, set to only patch.
marcus-talbot42
added a commit
that referenced
this issue
Sep 23, 2022
- Implemented Equalizer, which implements a type check, which allows BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map) to only map compatible collections. - Implemented BeanMapper#map(Collection, Collection), which maps a source collection, to a target collection, if both the elements of the source and target implement Equalizer and use the same class for their ID. - Implemented BeanMapper#map(Map, Map), which maps a source map, to a target map, if both the values of the source and target implement Equalizer and use the same class for their key/ID. - Both methods also map elements to the target that do not have a counterpart, simply mapping those elements to the target class. - Updated CHANGELOG.md - Added tests - Made the decision whether to patch or patch&insert a configurable option. By default, set to only patch.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sometimes you want to map a collection of sources into a collection of existing targets, e.g:
Collection forms = ...;
Collection entities = repository.findAll();
Collection results = beanMapper.map(forms, entities);
This would automatically select the comparable (equal) entity from the target list and map the source.
To compare entities an 'Equalizer' interface has to be created:
boolean equals(Object left, Object right)
With a default implementation that does an Object.equals(left, right), this is by default null safe.
The text was updated successfully, but these errors were encountered: