-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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.
- Loading branch information
1 parent
af478af
commit 71af903
Showing
11 changed files
with
419 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/io/beanmapper/core/collections/Equalizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package io.beanmapper.core.collections; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* An interface that may be implemented by a class, to make the class compatible with BeanMapper#map(Collection, Collection) and BeanMapper#map(Map, Map). | ||
*/ | ||
public interface Equalizer { | ||
|
||
/** | ||
* Tests whether the two classes are equal, for the purposes of mapping the calling object, to the target object. Default implementation should be | ||
* overridden for every implementing class. | ||
* @param target the target instance, to which the calling instance is looking to be mapped. | ||
* @return whether the caller and target are equal. | ||
* @param <T> the class of the target | ||
*/ | ||
default <T extends Equalizer> boolean isEqual(T target) { | ||
return Objects.equals(this, target); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.